Snake Game (Graphical Version using SDL2)
This is a graphical Snake Game developed in C language using the SDL2 library. It runs in a windowed graphical interface instead of the terminal.
- Graphical window interface
- Smooth snake movement
- Arrow key controls
- Random fruit spawning
- Score increases when fruit is eaten
- Snake grows after eating fruit
- Collision detection (wall and self)
- Game over when collision occurs
- Linux OS (Tested on Arch Linux)
- GCC Compiler
- SDL2 Library
Install SDL2 using:
sudo pacman -S sdl2
Compile the program using:
gcc snake_gui.c -o snake_gui -lSDL2
Execute:
./snake_gui
LEFT ARROW - Move Left RIGHT ARROW - Move Right UP ARROW - Move Up DOWN ARROW - Move Down Close Window - Exit Game
- The snake starts from the center.
- A fruit appears randomly on the screen.
- When the snake eats the fruit:
- Score increases by 10
- Snake length increases
- A new fruit appears randomly
- Game ends if:
- Snake hits the wall
- Snake hits its own body
- Add restart option
- Add sound effects
- Display score inside window
- Add difficulty levels
- Save high score to file
Developed as a C programming project to demonstrate basic game development using SDL2 in Linux.
========================================