A classic snake game written in C using SDL2, with a focus on SDL2 rendering and event handling. This project contains multiple builds and test files, but the main game logic lives in main2_actual_main.c.
This is a personal SDL2 game project structured to make building and running on Windows easy without needing to install SDL2 system-wide. SDL2 includes and libraries are bundled inside the project.
SDL_proj/
├── SDL2.dll
├── snake.c
├── snake.exe
├── test_sdl.c / test_sdl.exe
│
├── bgtsdl2/
│ ├── main2_actual_main.c ✅ Main game source file
│ ├── SDL2.dll
│ ├── main.c, main2.c Test files
│ ├── bin/
│ │ ├── main2_actual_main.exe ✅ Main game executable
│ ├── inc/ SDL2 header files
│ └── lib/ SDL2 libraries
│
├── inc/ Duplicate headers
└── lib/ Duplicate libs
On Windows:
- Navigate to
bgtsdl2/bin/ - Double-click
main2_actual_main.exe - Ensure
SDL2.dllis present in the same folder
✅ No installation or compilation required.
Requirements: MinGW or another GCC compiler
gcc bgtsdl2/main2_actual_main.c -Ibgtsdl2/inc -Lbgtsdl2/lib -lmingw32 -lSDL2main -lSDL2 -o bgtsdl2/bin/main2_actual_main.exe -mwindowsmain2_actual_main.cis the main entry point.- Files like
main.candsnake.care test builds. - Top-level
inc/andlib/folders are duplicates.
This project is provided as-is for learning/demo purposes. Feel free to fork and modify.
Commands used for compiling and executing the files in the terminal (PowerShell on Windows):
cd "c:\Users\user\SDL proj\bgtsdl2\" ; if ($?) { gcc main2.c -o bin/main2 } ; if ($?) { bin/main2 }gcc main2_actual_main.c -Iinc -Llib -lmingw32 -lSDL2main -lSDL2 -o bin/main2_actual_main.exe
.\bin\main2_actual_main.exe