Skip to content

arrecis/Snake-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ Snake Game

A simple Snake game implemented in C using the Raylib library.

๐Ÿ“‹ Requirements

  • Raylib - C game development library
  • C Compiler (GCC, MinGW, Visual Studio, etc.)
  • Windows/Linux/macOS

๐Ÿš€ Installation

1. Install Raylib

Windows (MinGW):

# Download from: https://www.raylib.com/
# Or use vcpkg:
vcpkg install raylib

Linux (Ubuntu/Debian):

sudo apt install libraylib-dev

macOS:

brew install raylib

2. Compile the game

Windows (MinGW):

gcc main.c -o snake.exe -lraylib -lopengl32 -lgdi32 -lwinmm

Linux:

gcc main.c -o snake -lraylib -lGL -lm -lpthread -ldl -lrt -lX11

macOS:

gcc main.c -o snake -lraylib

๐ŸŽฎ How to play

  1. Run the game:

    ./snake.exe    # Windows
    ./snake        # Linux/macOS
  2. Controls:

    • โฌ†๏ธ Up Arrow - Move up
    • โฌ‡๏ธ Down Arrow - Move down
    • โฌ…๏ธ Left Arrow - Move left
    • โžก๏ธ Right Arrow - Move right
    • Enter - Restart after Game Over
  3. Objective:

    • Eat the red food to grow
    • Avoid hitting the walls and yourself
    • Get the highest score!

๐Ÿ“ Project structure

snake/
โ”œโ”€โ”€ main.c          # Main source code
โ”œโ”€โ”€ README.md       # This file
โ””โ”€โ”€ .gitignore      # Files ignored by Git

๐Ÿ› ๏ธ Code features

  • Only 80 lines of code - Minimalist implementation
  • No external dependencies - Only Raylib
  • Static memory - No malloc/free
  • Efficient collision detection
  • Responsive controls

๐Ÿ› Troubleshooting

Error: "raylib.h not found"

  • Make sure you have Raylib installed correctly
  • Verify that include paths are configured

Linking error:

  • Check that you have all necessary libraries
  • On Windows, make sure you have Raylib DLLs

Game runs slowly:

  • The game is limited to 60 FPS
  • Speed can be adjusted by modifying frameCount >= 12 in the code

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿค Contributing

Improvements and suggestions are welcome! Feel free to fork and submit pull requests.

About

Simple snake game with Raylib

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages