Skip to content

MertYksl03/snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game in C with SDL2

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.

🕹️ Game Features

  • 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

💻 Technologies Used

  • C programming language
  • SDL2 for rendering graphics and handling input
  • Makefile for building the project

⚙️ Installation

  1. Install SDL2 on your system:

    • On Linux (Ubuntu/Debian):
      sudo apt-get install libsdl2-dev
    • On macOS (using Homebrew):
      brew install sdl2
  2. Clone this repository:

git clone https://github.com/MertYksl03/snake.git
cd snake
  1. Compile the game:
  make build
  1. Run the game:
./snake
  1. Exit the game: You can press q or escape keys to close the game

🎮 How to Play

  • 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.

📸 Screenshots

image image1 image2 image3

About

Basic Snake Game in C with SDL2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published