How to run in your webpage:
<script type="module">
import init from "consnake"
init()
</script>
This game listens for arrow key events once the game is running. The game only runs once it detects that devtools have been opened, but it is a silly toy that isn't the best way to play snake.
yarn serve
serves index.html
via http-server
, then at localhost:7777
open devtools to see the game
Further thoughts:
- random colours between games
- more games?
- better handle focus
- more options (size, colour, frame rate, etc)
- add start and game over states
Happy snaking!