This repository contains the code for a simple Snake game written in C, utilizing the SDL2 library for graphics and handling user input. The game features basic mechanics, including snake movement, food collection, and collision detection.
- Snake moves in four directions: up, down, left, and right.
- Snake grows longer every time it eats food.
- The game ends if the snake collides with the wall or itself.
- Different game modes:
- Random mod
- Walls enabled
- No walls
- C programming language
- SDL2 for rendering graphics and handling input
- Makefile for building the project
-
Install SDL2 on your system:
- On Linux (Ubuntu/Debian):
sudo apt-get install libsdl2-dev
- On macOS (using Homebrew):
brew install sdl2
- On Linux (Ubuntu/Debian):
-
Clone this repository:
git clone https://github.com/MertYksl03/snake.git
cd snake- Compile the game:
make build- Run the game:
./snake- Exit the game: You can press q or escape keys to close the game
- Use the arrow keys(up, down, left, right) or W, A, S, D keys to control the snake.
- Eat the food (represented by a square) to make the snake grow.
- Avoid hitting the walls or the snake's own body.
- You can toggle the walls with pressing the space key. (enabling or disabling walls)
- You can pause the game by pressing p key.
- To play random press x key.



