Please sign in to access this page

Snake Game

Snake Game Used AI

10 devlogs
16h 33m
•  Ship certified
Created by Dheeraj

The Snake Game is a classic arcade game where the player controls a snake that moves around the screen. The objective is to eat food items that appear randomly on the screen. Every time the snake eats the food, it grows longer. The game becomes more challenging as the snake gets longer and faster. The player must avoid colliding with the snake’s own body and the screen boundaries. If the snake crashes, the game is over.

This game helps improve focus, reaction time, and strategic thinking, and is a popular beginner project for learning programming concepts like loops, collision detection, and event handling.

Timeline

Ship 1

0 payouts of shell 0 shells

Dheeraj

6 days ago

Dheeraj Covers 10 devlogs and 16h 33m

I have five different themes implemented in the game. They are:

1.Dark

2.Light

3.Neon

4.Retro

5.Matrix

Players can cycle through all five themes by clicking a button or using a specific keybind, which triggers the toggleTheme function. This makes it easy to switch up the visual style whenever you want.

Update attachment

I designed the game now in two modes—Classic Mode with visible walls like in old Nokia phones, and Enhanced Mode with extra features like wrap-around movement, colorful food, and bonus points. I added a start menu where users can choose the mode they want to play, and also included a “Back to Menu” button so they can switch modes without refreshing the page.

Update attachment

I improved my Snake Game by adding some fun and interactive features. Now there's a dark and light mode toggle, colorful bonus food that gives extra points, and a smooth trail effect behind the snake. I also added sound effects for eating and game over to make the game feel more alive.

Update attachment

I improved the Game to make it more fun and engaging. I added colorful food, sound effects for eating and game over, and made the snake speed up as the score increases. I also enhanced the UI with better score display, a clean pause message, and a smoother restart. Overall, it feels faster, more responsive, and more visually interesting."

Update attachment

After the game ended and the Game Over message appeared, pressing the spacebar would still trigger the Game Paused message.
I added a new variable called isGameOver to my code. This variable acts like a switch that tells me if the game is still running or if it has ended. I made sure that when the game starts, isGameOver is set to false. When the snake hits a wall or itself, I set isGameOver to true, which lets the program know the game is finished. The most important change was updating the keydown event listener. Now, before it does anything, it checks the isGameOver variable. This prevents the spacebar from pausing a game that has already ended and also stops the directional keys from being able to move the snake.

Update attachment

I updated the Snake game! Now, it includes a high score feature that keeps track of my best score using the browser's local storage. I also made a small tweak to the display to show both the current score and the high score, and adjusted the spacing for a cleaner look.

Update attachment

I added a Pause/Resume feature to my Snake Game. Now, when you press the spacebar, the game pauses, showing a Game Paused ⏸️ message, and pressing space again resumes it. This was done by adding a isPaused flag, displaying a pause message, and modifying the game loop to skip updates when paused. The game state, snake, and score remain intact during the pause.

Update attachment

Previously, the game starts with the snake not moving until you press an arrow key, which feels awkward and less intuitive.
What did I improve?
=>I set an initial direction (velocity = {x: 1, y: 0}) so the snake automatically starts moving to the right as soon as the game begins. The player can still change direction anytime.

Update attachment

I removed the reload and implemented a manual restart mechanism using JavaScript. When the game ends, it:

Stops the game loop with clearInterval()

Displays a Game Over message and a Play Again button

On button click, the game is reset by reinitializing all variables and starting a new game loop — without refreshing the page

Update attachment

Today,I worked on the logic and a simple Gui using html,css and java script.
Right now it is working and I will be modifying this into an interesting and fun game.

Update attachment