A terminal-based Snake game written in C with PDCurses. This project was built as a data structures course project and kept public as a small, complete systems-style program that demonstrates game loop design, state management, and array-based movement logic.
- Gameplay video: videos/screen_record.mp4
- Built in C with a lightweight terminal UI
- Menu system, pause flow, about page, and mode selection
- Three speed modes: slow, medium, fast
- Score tracking and elapsed time display
- Wrap-around wall behavior
- Random food generation that avoids the snake body
- Cross-platform build path: bundled PDCurses for Windows, curses via CMake on Unix-like systems
This repository is worth showing publicly because the implementation is small but explicit:
- The snake body is stored in a fixed-size array of
Pointnodes - Movement is handled by shifting body segments forward each frame
- Direction updates prevent immediate reversal into the snake body
- Food generation retries until it lands outside occupied cells
- Game state is modeled with an enum-based state machine: menu, playing, paused, game over, about, and mode selection
- C99
- PDCurses
- CMake
This repository vendors PDCurses, so the simplest path is to use CMake:
cmake -S . -B build
cmake --build build --config ReleaseInstall a curses implementation first, then build with CMake:
cmake -S . -B build
cmake --build build./build/GreedySnakeOn Windows with a multi-config generator, the executable may be under build/Release/GreedySnake.exe.
- Arrow keys: move
P: pause / resumeESCorQ: return to menuEnter: confirm menu selection
src/main.c: entry point and main loopsrc/game.c: game state updates, scoring, speed, wall handlingsrc/snake.c: snake movement and self-collision logicsrc/food.c: food placementsrc/input.c: keyboard handling and menu interactionsrc/ui.c: terminal rendering
This is not just a classroom archive. It is a compact C project that shows:
- basic data structure implementation
- terminal UI programming
- state machine design
- clean separation between input, game logic, and rendering
MIT