Skip to content

loopholend/snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐍 SFML Snake Game

A polished, modern take on the classic Snake game, built with C++ and the SFML multimedia library. Featuring multiple difficulty levels, dynamic obstacles, bonus food, and robust, modular game logic.


🚀 Overview

This project is a clean, expandable implementation of Snake, ideal for both players and developers looking to learn or extend a C++/SFML game. All core mechanics are encapsulated in a SnakeGame class, making the codebase easy to understand and maintain.

Food spawning is carefully handled so that new food never appears on the snake, obstacles, or UI elements, ensuring frustration-free gameplay.


🕹️ Features

  • Multiple Difficulty Levels: Choose from Easy, Medium, or Hard
  • Dynamic Obstacles: Obstacle number and placement scale with difficulty
  • Bonus Food: Special timed food items for extra points
  • Smart Spawning Logic: Food and bonuses never spawn in invalid locations
  • Clean UI: Score panel at the top of the screen

🎮 Controls

  • Arrow Keys: Move the snake
  • ESC: Pause or exit

Goal: Eat as much food as possible to grow your snake and increase your score. Avoid colliding with walls, obstacles, or your own tail.


🛠️ Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/loopholend/snake.git
  2. Install SFML

    • Download the version matching your compiler (e.g. GCC for MinGW-w64, 64-bit) from SFML Downloads
    • Extract it to a stable location (e.g. C:/dev/SFML-2.6.2)
  3. Configure CMake

    • Open the project in your IDE.
    • Edit CMakeLists.txt: Update the set(SFML_DIR ...) line to your SFML installation path.
    set(SFML_DIR "C:/dev/SFML-2.6.2/lib/cmake/SFML")
    • Ensure the following lines appear:
    find_package(SFML 2.6 COMPONENTS graphics window system REQUIRED)
    target_link_libraries(snake PRIVATE sfml-graphics sfml-window sfml-system)
  4. Copy SFML DLLs (Windows only)

    • Copy all .dll files from C:/dev/SFML-2.6.2/bin to your project's build output folder (typically cmake-build-debug/)
  5. Build and Run

    • Reload the CMake project in your IDE
    • Build and run – the game should launch!

🩹 Troubleshooting

  • 0xc000007b Error: 32/64-bit mismatch. Ensure both compiler and SFML are 64-bit.
  • Missing DLLs: Copy all SFML .dll files to your build output folder.
  • CMake can't find SFML: Make sure SFML_DIR in CMakeLists.txt is correct and points to the folder containing SFMLConfig.cmake.

📄 License

This project is licensed under the MIT License. See LICENSE.txt for details.


🙏 Acknowledgments

About

Classic snake game built in C++ with SFML featuring obstacles, bonus food, and multiple difficulty levels.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors