Skip to content

Latest commit

 

History

History
86 lines (58 loc) · 2.23 KB

README.md

File metadata and controls

86 lines (58 loc) · 2.23 KB

Snake Game

This is a simple Piston snake game.

Installation

To install and run the game, clone this repository and run the following command:

cargo run

How to play

The goal of the game is to control the snake and eat as many apples as possible without hitting itself or the edge of the screen. Use the arrow keys to move the snake.

Documentation

Here is a brief overview of the game's classes:

Game

The Game struct represents the overall game state. It contains the following attributes:

  • gl: A GlGraphics object used to render the game.
  • snake: A Snake object representing the snake.
  • apple: An Apple object representing the apple.
  • game_update: A bool value indicating whether the game is currently being updated.

Snake

The Snake struct represents the snake in the game. It contains the following attributes:

  • body: A LinkedList containing the coordinates of the snake's body segments.
  • dir: A Direction enum value indicating the direction in which the snake is moving.

Apple

The Apple struct represents the apple in the game. It contains the following attributes:

  • x: The x-coordinate of the apple.
  • y: The y-coordinate of the apple.

Conclusion

This is a simple Piston snake game. You can use the arrow keys to move the snake and try to eat as many apples as possible before the game is over.