Basic Snake HTML and JavaScript Game
Snake is a fun game to make as it doesn't require a lot of code (less than 100 lines with all comments removed). This is a basic implementation of the snake game, but it's missing a few things intentionally and they're left as further exploration for the reader.
Create a fun Snake game with <100 lines of code using HTML and JavaScript. Basic version with room for exploration.
Further Exploration
- Score
- When the snake eats an apple, the score should increase by one. Use context.fillText() to display the score on the screen
- Mobile and touchscreen support
- Allow the game to be scaled down to a phone size. See HERE
- Support touch controls
- Better apple spawning
- Currently, the apple spawns in any random grid in the game, even if the snake is already on that spot. Improve it so it only spawns in empty grid locations
Important note: I will answer questions about the code but will not add more features or answer questions about adding more features.
Source Code
You Can Download The Full Code With Documentation From The Download Button Given Below
License
(CC0 1.0 Universal) You're free to use this game and code in any project, personal or commercial. There's no need to ask permission before using these. Giving attribution is not required, but is appreciated.
0 Comments