DEVLOG -16
This time I added Capy Snake! ๐๐ Because apparently CAPY was getting bored of sleeping all day.
Built a classic Snake game using HTML Canvas and vanilla JavaScript. Added a 20ร20 grid, arrow-key movement, oranges to collect, scoring, high scores, and Start/Pause/Restart buttons.
For the code, I made a separate snake.js file. Used an array to store the snakeโs body, setInterval() to move it, and unshift() / pop() to update its position. When the snake eats an orange, it grows, and every 3 oranges the speed increases. High scores are saved using localStorage.
Also added wall and self-collision detection, so CAPY canโt just eat himself and pretend nothing happened ๐
Had some funny bugs along the way. First I typed fillReact() instead of fillRect() and the entire game board disappeared. Then I had to give the snake a tiny black eye because I couldnโt even tell which side was its head ๐ญ
Special thanks to these GitHub projects for helping me understand the game logic:
Their code helped me understand how Snake games work, and I used those ideas to build my own version for BASIX OS. Thanks to the creators!
CAPY finally has a game to play. Unfortunately, he keeps eating himself. ๐ฆซ๐
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.