Files
Hermit/fixtures/snake_cpp

Snake Game

A classic terminal-based Snake game written in C++17.

Features

  • Smooth snake movement using POSIX terminal I/O
  • WASD or Arrow keys for movement
  • Food spawning and snake growth
  • Wall and self-collision detection
  • Score tracking
  • Pause functionality (P key)
  • Clean terminal rendering

Build

make

This compiles snake.cpp with optimization level O2 and C++17 standard.

Run

./snake

Controls

Key Action
W / ↑ Move Up
S / ↓ Move Down
A / ← Move Left
D / → Move Right
P Pause/Resume
Q Quit

Game Rules

  • Eat the * food to grow and score points (+10 per food)
  • Avoid hitting the walls #
  • Avoid colliding with your own body o
  • The snake moves continuously

Requirements

  • GCC/G++ with C++17 support
  • POSIX-compliant system (Linux, macOS)
  • Terminal with ANSI escape support