Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Snake (C++ / SFML)

A small arcade-style Snake game made with C++17 and SFML 3. Eat food to grow, avoid crashing into walls or your own tail, and try to beat your best score.

Controls

Action Keys
Move A / D or Left / Right Arrow
Move Up/Down W / S or Up / Down Arrow
Restart after losing Enter

Requirements

  • CMake 3.16 or newer
  • A C++17 compiler (Visual Studio 2022 on Windows is recommended)
  • SFML 3, built for the same compiler architecture as the project (normally 64-bit)

Install SFML on Windows

  1. Download the SFML 3 Windows package that matches your Visual Studio version and architecture from SFML's download page.

  2. Extract it to a stable location, such as C:/SFML-3.0.0.

  3. Its CMake configuration folder should look like this:

    C:/SFML-3.0.0/lib/cmake/SFML
    

The project does not hard-code an SFML installation path. Pass SFML_DIR while configuring if CMake cannot find your copy.

Build and run (Visual Studio / Windows)

Run these commands from the project folder in PowerShell:

cmake -S . -B build -DSFML_DIR="C:/SFML-3.0.0/lib/cmake/SFML"
cmake --build build --config Debug
.\build\Debug\Snake.exe

For a Release build, replace Debug with Release in the last two commands.

The build automatically copies the SFML DLL files beside Snake.exe, so the game can start without manually copying the library files.

Troubleshooting

CMake says it cannot find SFML

Check that SFML_DIR points to the folder containing SFMLConfig.cmake, then configure again:

cmake -S . -B build -DSFML_DIR="C:/your-sfml-folder/lib/cmake/SFML"

If CMake saved an old path, remove only the generated build directory and rerun the configure command.

The game does not start because an SFML DLL is missing

Build the project with CMake rather than running a manually copied executable. The POST_BUILD step in CMakeLists.txt copies the required SFML DLLs next to the game executable.

Font error

The game loads C:/Windows/Fonts/arial.ttf; this is available on standard Windows installations. If that file is missing, change the font path in Snake.cpp to a font installed on your computer.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages