Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/abhipatel35/snakegame-java

Snake Game: A classic implementation of the popular Snake game in Java using Swing. Control the snake, eat apples, and avoid collisions to win!
https://github.com/abhipatel35/snakegame-java

basic-game-development event-driven-programming game game-development graphics-programming java java-constructor snake-game swing swing-gui user-input-handling

Last synced: 7 days ago
JSON representation

Snake Game: A classic implementation of the popular Snake game in Java using Swing. Control the snake, eat apples, and avoid collisions to win!

Awesome Lists containing this project

README

        

# Snake Game

This is a simple Snake game implemented in Java using Swing. The game window is a grid where the snake moves around. The objective is to eat the red apples that randomly appear on the grid, which causes the snake to grow longer. The game ends if the snake collides with itself or the boundaries of the grid.

## How to Play

- Use the arrow keys (up, down, left, right) to control the direction of the snake.
- The snake will continuously move in the direction it is facing.
- The game ends if the snake collides with itself or the boundaries of the grid.
- Press 'R' to restart the game after it ends.

## Game Controls

- **Up Arrow:** Move the snake upwards.
- **Down Arrow:** Move the snake downwards.
- **Left Arrow:** Move the snake to the left.
- **Right Arrow:** Move the snake to the right.
- **R:** Restart the game after it ends.

## Features

- Responsive keyboard controls.
- Simple graphics using basic shapes.
- Game over message with option to restart.

## Developer Notes

This game project demonstrates basic game development concepts in Java, including graphics rendering, user input handling, game logic, and event-driven programming.

## How to Run

1. Make sure you have Java installed on your system.
2. Compile the `SnakeGame.java` file using `javac SnakeGame.java`.
3. Run the compiled Java file using `java SnakeGame`.

Enjoy playing the Snake game! If you encounter any issues or have feedback, feel free to open an issue or submit a pull request.