Live data from Hacker News

Snake in Elm with WebGL

github.com

1–10 of 29 posts

Re: Snake in Elm with WebGL

#3
post #2

How is the actual game loop executed? I don't know Elm but I only find update, not how it's run.

The function `Html.program`, in `main`, takes an update function which handles (among other things) ticking the game loop.

http://package.elm-lang.org/packages/elm-lang/html/latest/Ht...

Re: Snake in Elm with WebGL

#5
I attended a two day Elm workshop a while back. There is a lot there to love, I just think it's Haskell inspired syntax is a major impediment to it's mainstream adoption. I however would love to be proven wrong as the webs reliability would be so remarkably improved.

Re: Snake in Elm with WebGL

#6
post #5

I attended a two day Elm workshop a while back. There is a lot there to love, I just think it's Haskell inspired syntax is a major impediment to it's mainstream adoption. I however would love to be proven wrong as the webs reliability would be so remarkably improved.

Imho, Elm's syntax is more akin to OCaml than to Haskell. Besides OCaml, it reminds me a lot of F#.

Re: Snake in Elm with WebGL

#7
post #5

I attended a two day Elm workshop a while back. There is a lot there to love, I just think it's Haskell inspired syntax is a major impediment to it's mainstream adoption. I however would love to be proven wrong as the webs reliability would be so remarkably improved.

Here's a challenge for you: what syntax would be better? I don't mean that in a derogatory way. I think you are right that the syntax (being very foreign to people) does provide an impediment, but puzzling out how to implement the same functionality with a more familiar syntax would be extremely difficult (though potentially very fun).

Re: Snake in Elm with WebGL

#9
post #4

Bug: Create snake of length two. Move RIGHT. Quickly press UP LEFT in quick succession. Lose. Similar bug with RIGHT->DOWN->LEFT And so on for all the other initial directions.

Not the author, but I've implemented my own snake game and this bug is fairly easy to kill.

(1) - You can only change directions that will change your axis, if you're going left your possible changes are up and down, ....

(2) - You should be only able to consume one direction change per game tick, what is happening here is that rule (1) is working but you can change into the other axis, and then back to the other axis again before the game loop computes another frame. Direction change can be read asynchronously but the actual change should be tied by each tick.

Post reply on HN