Skip to content

Latest commit

 

History

History
12 lines (11 loc) · 861 Bytes

README.md

File metadata and controls

12 lines (11 loc) · 861 Bytes

C Snake Game

A doubly-linked list based snake clone written in C.

  • The snake is represented as a doubly-linked list, where each section is a node.
  • Moving forwards involves popping the tail node from the list, and prepending it to the head. Its coordinates are then modified in respect to the direction the snake is moving.
  • When an apple is touched, its new position is randomized (ensuring that the apple is not spawned on the snake)
  • Adding to the snake allocates the memory for a new node, and prepends it to the snake, becoming the new head.
  • The game is written using ncurses for keyboard input and improved screen printing to terminal

Example

Example Snake Image

  • The game board size can be set in the header file
  • Touching the walls or running into your tail ends the game.