I am learning elm-ui and decided to make something fun. This is a classic snake game created with elm-ui. Just to give it a boost, this version has the food replenished in batches, not one by one.
The game is over if the snake bites itself or it hits
the wall.
Snake grows with each chomp.
The longer the snake, the faster it moves.
The game is controlled only from keyboard, so please make sure you have focus
on the game page. Or just focus on it by clicking the start screen.
You can tweak the Config to change the game defaults.
Thanks, Brian. I like to start with these toy projects. They are not overly complex, yet they provide a good fun start for those new to the language.
I have just posted this in #gamedev on Slack.
Is it a design choice that pressing in the opposite direction you’re traveling is an instant game over? I prefer the “pressing opposite direction of travel does nothing” control strategy, meself.
EDIT: There is also a heavy enough input delay that a fast 180 (such as when going up, quickly press left then down) also gives a game over. It’s like all input goes into a buffer, with each input erasing the last input, until that buffer gets sampled at regular intervals.
I’d instead recommend a LIFO buffer where every game step pops one input event off the buffer. Then validity of input (such as ignoring input in reverse direction to current travel) check would happen on pop.
Elm is meant to be easy to refactor and modify on the fly, this might give one an opportunity to discern how true that is.