Gra platformowa 2D w C++17 z biblioteką SFML 2.x. Gracz przechodzi kampanię czterech poziomów, zbiera monety, skacze (triple jump), strzela pociskami poziomo, unika lub eliminuje wrogów patrolujących platformy. Są animacje sprite’ów, SFX, muzyka i parallax z innym zestawem teł na każdym poziomie (m.in. grafiki Kenney — las, pustynia, zamek, noc). Menu główne, ekran Top 10 oraz zapis wyników do scores.json (łączna liczba monet z całej kampanii i czas).
- C++17
- CMake >= 3.20
- SFML 2.5+ (gałąź 2.x — nie 3.x)
brew install sfmlsudo apt install libsfml-dev
CMakeLists.txtzawiera ścieżki zakodowane na sztywno i oczekuje, że vcpkg znajduje się dokładnie wC:\game2d\vcpkg, a biblioteka SFML wC:\game2d\vcpkg\vcpkg_installed\x64-windows. Poniższe kroki tworzą dokładnie taki układ, więc projekt zbuduje się bez modyfikowaniaCMakeLists.txt.
1. Zainstaluj narzędzia. Pobierz i zainstaluj Visual Studio 2022 z zestawem „Desktop development with C++" (zawiera kompilator MSVC, CMake i Ninja) oraz Git for Windows.
2. Otwórz konsolę dewelopera. Z menu Start uruchom „Developer Command Prompt
for VS 2022" (ma już ustawiony kompilator w PATH).
3. Zainstaluj vcpkg i SFML dokładnie w C:\game2d\vcpkg:
git clone https://github.com/microsoft/vcpkg C:\game2d\vcpkg
cd C:\game2d\vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg install sfml:x64-windows4. Utwórz dowiązanie vcpkg_installed wymagane przez CMakeLists.txt
(klasyczny tryb vcpkg instaluje do installed\, a projekt szuka w
vcpkg_installed\):
mklink /J C:\game2d\vcpkg\vcpkg_installed C:\game2d\vcpkg\installed5. Zbuduj grę (z katalogu projektu):
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=C:\game2d\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake --build build --config ReleaseCMake po zbudowaniu sam kopiuje folder assets/ oraz potrzebne biblioteki DLL
SFML obok pliku .exe.
6. Uruchom grę:
cd build\Release
Platformer.exemkdir build
cd build
cmake ..
cmake --build .Plik wykonywalny: Platformer (Windows: Platformer.exe).
Folder assets/ jest kopiowany automatycznie do katalogu z binarką po każdym buildzie.
cd build
./Platformer # macOS / Linux| Klawisz / akcja | Opis |
|---|---|
↑ / ↓ |
Poruszanie po opcjach |
| Ruch myszy | Podświetlenie opcji pod kursorem |
Enter / LPM |
Wybór opcji |
| Klawisz | Akcja |
|---|---|
A / ← |
Ruch w lewo |
D / → |
Ruch w prawo |
↑ |
Skok (do 3× w powietrzu) |
Spacja |
Strzał (pocisk poziomy, cooldown) |
| Klawisz | Akcja |
|---|---|
R |
Natychmiastowy restart (Game Over) |
Escape |
Powrót do menu (Game Over) |
Enter |
Zatwierdź nick po wygranej → powrót do menu |
- Gra startuje w menu głównym z animowanym tłem parallax.
- Kampania: kolejno 4 poziomy — po zebraniu wszystkich monet na bieżącym poziomie następuje przejście do następnego; po ostatnim — ekran wygranej.
- Gracz ma 3 życia — wypadnięcie poza dolną krawędź mapy powoduje respawn i utratę życia (kolizja z wrogiem też).
- Brak żyć → ekran GAME OVER (R = restart od poziomu 1, Escape = menu).
- Wrogowie patrolują w poziomie; pociski je dezaktywują.
- Monety — zebrane znikają i zwiększają licznik; wynik w
scores.jsonuwzględnia sumę monet z całej ukończonej kampanii oraz czas. - Ekran YOU WIN z formularzem na nick — po zatwierdzeniu zapis do
scores.json. - Top 10 — wyniki sortowane rosnąco po czasie (szybciej = wyżej).
| Opcja | Akcja |
|---|---|
| Start | Rozpoczyna kampanię od poziomu 1 |
| Najlepsze wyniki | Ekran Top 10 z scores.json |
| Wyjdź | Zamknięcie gry |
Coins: X / Y— monety na aktualnym poziomieLevel: N / 4Lives: XTime: MM:SS
Plik tworzony / dopisywany po wygranej — jeden wpis na linię:
{"name":"Jan","time":"1:23","coins":15}Pole coins to łączna liczba monet zebranych w ukończonej kampanii. Ekran Top 10 wczytuje plik przy każdym otwarciu, sortuje po czasie i wyświetla maksymalnie 10 wyników.
Gra nie crashuje przy braku plików — działa bez dźwięku lub bez tekstury (np. wrogowie mają wtedy prosty kolorowy prostokąt zamiast sprite’u).
| Ścieżka | Opis |
|---|---|
assets/textures/player_sheet.png |
Spritesheet gracza (9 kolumn × 3 wiersze, klatki 80×110 px) |
assets/textures/bg_clouds.png |
Warstwa parallax — chmury |
assets/textures/bg_mountains.png |
Warstwa parallax — góry |
assets/textures/bg_trees.png |
Warstwa parallax — drzewa |
assets/textures/parallax/l1_*.png … l3_*.png |
Zestawy tła pod poziomy 2–4 (Kenney Background Elements, m.in. pustynia / zamek / noc) |
assets/textures/enemies/zombie_walk1.png, zombie_walk2.png |
Klatki animacji chodu wroga (Kenney Platformer Characters) |
Pociski są rysowane jako mały prostokąt (bez osobnej tekstury).
| Ścieżka | Zdarzenie |
|---|---|
assets/sounds/jump.ogg |
Skok gracza |
assets/sounds/coin.ogg |
Zebranie monety |
assets/sounds/death.ogg |
Utrata życia / respawn |
assets/sounds/gameover.ogg |
Game over |
assets/sounds/shoot.ogg |
Wystrzelenie pocisku (Kenney Interface Sounds — pluck_001) |
| Ścieżka | Kiedy gra |
|---|---|
assets/music/menu.ogg |
Menu główne (pętla) |
assets/music/gameplay.ogg |
Podczas rozgrywki (pętla) |
assets/music/gameover.ogg |
Ekran game over |
assets/music/win.ogg |
Ekran wygranej |
Pliki muzyczne w repozytorium pochodzą z paczki Kenney Music Jingles (CC0).
| Ścieżka | Opis |
|---|---|
assets/fonts/Roboto-Regular.ttf |
Czcionka HUD i UI (Google Fonts, OFL) |
Wiele plików graficznych i dźwiękowych oznaczonych jako pochodzące z Kenney jest na licencji CC0 (domena publiczna). Tekstury parallax w assets/textures/parallax/ pochodzą z paczki Kenney Background Elements (Flat / PNG). Szczegóły w License.txt w paczce źródłowej.
.
├── CMakeLists.txt
├── README.md
├── assets/
│ ├── fonts/
│ │ └── Roboto-Regular.ttf
│ ├── music/
│ │ ├── menu.ogg
│ │ ├── gameplay.ogg
│ │ ├── gameover.ogg
│ │ └── win.ogg
│ ├── sounds/
│ │ ├── jump.ogg
│ │ ├── coin.ogg
│ │ ├── death.ogg
│ │ ├── gameover.ogg
│ │ └── shoot.ogg
│ └── textures/
│ ├── player_sheet.png
│ ├── bg_clouds.png
│ ├── bg_mountains.png
│ ├── bg_trees.png
│ ├── parallax/
│ │ ├── l1_far.png … l1_near.png
│ │ ├── l2_far.png … l2_near.png
│ │ └── l3_far.png … l3_near.png
│ └── enemies/
│ ├── zombie_walk1.png
│ └── zombie_walk2.png
├── files/
│ ├── analiza_kodu.md
│ ├── spec_01_sprite_gracza.md … spec_10_wrogowie_strzal.md
│ └── …
└── src/
├── main.cpp
├── Game.h / Game.cpp
├── Player.h / Player.cpp
├── Platform.h / Platform.cpp
├── Coin.h / Coin.cpp
├── Level.h / Level.cpp
├── Enemy.h / Enemy.cpp
├── Projectile.h / Projectile.cpp
├── Animator.h / Animator.cpp
├── AudioManager.h / AudioManager.cpp
└── ParallaxLayer.h / ParallaxLayer.cpp
| Klasa | Odpowiedzialność |
|---|---|
Game |
Pętla gry, stany (MENU/PLAYING/GAME_OVER/WINNING/SCORES), HUD, muzyka, parallax, kampania poziomów, pociski, wyniki |
Player |
Fizyka, input, animacje, sprite, życia |
Level |
Ładowanie platform, monet i wrogów, kolizje gracza |
Platform |
Prostokąt kolizyjny platformy |
Coin |
Moneta — pozycja, stan zebrania |
Enemy |
Wróg — patrol, rysunek / animacja |
Projectile |
Pocisk gracza — ruch poziomy, kolizje |
Animator |
Spritesheet — zarządzanie klatkami animacji |
AudioManager |
Ładowanie i odtwarzanie krótkich SFX |
ParallaxLayer |
Jedna warstwa tła z efektem paralaksy |
Repozytorium łączy kod własny z zasobami z zewnątrz, więc licencja nie jest jednolita:
| Część | Licencja |
|---|---|
Kod źródłowy (src/, CMakeLists.txt) |
MIT — Copyright (c) 2026 Wojciech Wypych (Iakirmon) |
| Tekstury, dźwięki i muzyka z paczek Kenney | CC0 1.0 — domena publiczna |
assets/fonts/Roboto-Regular.ttf (Roboto 3.015) |
SIL Open Font License 1.1 — assets/fonts/OFL.txt |
| SFML | zlib/png — zależność zewnętrzna, nie jest częścią repozytorium |
MIT obejmuje kod, nie zasoby. Czcionka Roboto pozostaje na OFL 1.1, a jej tekst licencji jest dołączony do repozytorium, bo OFL wymaga tego przy redystrybucji.
A 2D platformer in C++17 using SFML 2.x. The player plays a four-level campaign, collects coins, performs a triple jump, shoots horizontal projectiles, and avoids or defeats patrolling enemies on platforms. Sprite animations, SFX, music, and per-level parallax (forest, desert, castle, night — Kenney assets) are included. Main menu, Top 10 leaderboard, and JSON score file (scores.json — total coins over the full run and time).
- C++17
- CMake >= 3.20
- SFML 2.5+ (branch 2.x — not 3.x)
brew install sfmlsudo apt install libsfml-dev
CMakeLists.txthas hardcoded paths and expects vcpkg at exactlyC:\game2d\vcpkg, with SFML inC:\game2d\vcpkg\vcpkg_installed\x64-windows. The steps below create exactly that layout, so the project builds without editingCMakeLists.txt.
1. Install the tools. Install Visual Studio 2022 with the "Desktop development with C++" workload (provides the MSVC compiler, CMake and Ninja) and Git for Windows.
2. Open the developer console. From the Start menu launch "Developer
Command Prompt for VS 2022" (the compiler is already on PATH).
3. Install vcpkg and SFML exactly in C:\game2d\vcpkg:
git clone https://github.com/microsoft/vcpkg C:\game2d\vcpkg
cd C:\game2d\vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg install sfml:x64-windows4. Create the vcpkg_installed junction required by CMakeLists.txt
(classic vcpkg installs into installed\, but the project looks in
vcpkg_installed\):
mklink /J C:\game2d\vcpkg\vcpkg_installed C:\game2d\vcpkg\installed5. Build the game (from the project directory):
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=C:\game2d\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake --build build --config ReleaseAfter building, CMake automatically copies the assets/ folder and the required
SFML DLLs next to the .exe.
6. Run the game:
cd build\Release
Platformer.exemkdir build
cd build
cmake ..
cmake --build .Executable: Platformer (Windows: Platformer.exe).
The assets/ folder is copied automatically to the binary directory after each build.
cd build
./Platformer # macOS / Linux| Key / action | Description |
|---|---|
↑ / ↓ |
Navigate menu options |
| Mouse move | Highlight option under cursor |
Enter / LMB |
Select option |
| Key | Action |
|---|---|
A / ← |
Move left |
D / → |
Move right |
↑ |
Jump (up to 3× in the air) |
Space |
Shoot (horizontal projectile, cooldown) |
| Key | Action |
|---|---|
R |
Instant restart (Game Over) |
Escape |
Return to menu (Game Over) |
Enter |
Confirm name after winning → back to menu |
- The game starts at the main menu with an animated parallax background.
- Campaign: 4 levels in sequence — collecting all coins on the current level advances to the next; after the last level, the win screen appears.
- The player has 3 lives — falling off the bottom of the map costs a life and respawns (enemy contact also hurts).
- No lives left → GAME OVER (R = restart from level 1, Escape = menu).
- Enemies patrol horizontally; projectiles deactivate them on hit.
- Coins — collected coins disappear and increase the counter; the entry in
scores.jsonstores the total coins collected over the completed campaign and the time. - YOU WIN screen with a name field — confirm to append to
scores.json. - Top 10 — scores sorted ascending by time (faster = higher rank).
| Option | Action |
|---|---|
| Start | Start the campaign from level 1 |
| Best scores | Top 10 screen from scores.json |
| Exit | Close the game |
Coins: X / Y— coins on the current levelLevel: N / 4Lives: XTime: MM:SS
Created or appended after a win — one JSON object per line:
{"name":"Jan","time":"1:23","coins":15}The coins field is the total coins collected in the finished campaign. The Top 10 screen loads the file on every open, sorts by time, and shows at most 10 entries.
The game does not crash on missing files — it can run without sound or without a given texture (e.g. enemies fall back to a simple colored rectangle if sprites fail to load).
| Path | Description |
|---|---|
assets/textures/player_sheet.png |
Player spritesheet (9 cols × 3 rows, 80×110 px frames) |
assets/textures/bg_clouds.png |
Parallax layer — clouds |
assets/textures/bg_mountains.png |
Parallax layer — mountains |
assets/textures/bg_trees.png |
Parallax layer — trees |
assets/textures/parallax/l1_*.png … l3_*.png |
Background sets for levels 2–4 (Kenney Background Elements) |
assets/textures/enemies/zombie_walk1.png, zombie_walk2.png |
Enemy walk animation frames (Kenney Platformer Characters) |
Projectiles are drawn as a small rectangle (no dedicated texture).
| Path | Event |
|---|---|
assets/sounds/jump.ogg |
Player jump |
assets/sounds/coin.ogg |
Coin collected |
assets/sounds/death.ogg |
Life lost / respawn |
assets/sounds/gameover.ogg |
Game over |
assets/sounds/shoot.ogg |
Projectile fired (Kenney Interface Sounds — pluck_001) |
| Path | When it plays |
|---|---|
assets/music/menu.ogg |
Main menu (loop) |
assets/music/gameplay.ogg |
During gameplay (loop) |
assets/music/gameover.ogg |
Game over screen |
assets/music/win.ogg |
Win screen |
Music files in the repo come from the Kenney Music Jingles pack (CC0).
| Path | Description |
|---|---|
assets/fonts/Roboto-Regular.ttf |
HUD and UI font (Google Fonts, OFL) |
Many assets credited to Kenney are CC0 (public domain). Parallax files under assets/textures/parallax/ come from Kenney Background Elements. See each pack’s License.txt for details.
.
├── CMakeLists.txt
├── README.md
├── assets/
│ ├── fonts/
│ │ └── Roboto-Regular.ttf
│ ├── music/
│ │ ├── menu.ogg
│ │ ├── gameplay.ogg
│ │ ├── gameover.ogg
│ │ └── win.ogg
│ ├── sounds/
│ │ ├── jump.ogg
│ │ ├── coin.ogg
│ │ ├── death.ogg
│ │ ├── gameover.ogg
│ │ └── shoot.ogg
│ └── textures/
│ ├── player_sheet.png
│ ├── bg_clouds.png
│ ├── bg_mountains.png
│ ├── bg_trees.png
│ ├── parallax/
│ │ ├── l1_far.png … l1_near.png
│ │ ├── l2_far.png … l2_near.png
│ │ └── l3_far.png … l3_near.png
│ └── enemies/
│ ├── zombie_walk1.png
│ └── zombie_walk2.png
├── files/
│ ├── analiza_kodu.md
│ ├── spec_01_sprite_gracza.md … spec_10_wrogowie_strzal.md
│ └── …
└── src/
├── main.cpp
├── Game.h / Game.cpp
├── Player.h / Player.cpp
├── Platform.h / Platform.cpp
├── Coin.h / Coin.cpp
├── Level.h / Level.cpp
├── Enemy.h / Enemy.cpp
├── Projectile.h / Projectile.cpp
├── Animator.h / Animator.cpp
├── AudioManager.h / AudioManager.cpp
└── ParallaxLayer.h / ParallaxLayer.cpp
| Class | Responsibility |
|---|---|
Game |
Game loop, states (MENU/PLAYING/GAME_OVER/WINNING/SCORES), HUD, music, parallax, level campaign, projectiles, scores |
Player |
Physics, input, animations, sprite, lives |
Level |
Loading platforms, coins, enemies; player collisions |
Platform |
Platform collision rectangle |
Coin |
Coin — position and collected state |
Enemy |
Enemy — patrol, drawing / animation |
Projectile |
Player projectile — horizontal motion, collisions |
Animator |
Spritesheet — animation frame management |
AudioManager |
Loading and playing short SFX |
ParallaxLayer |
Single background layer with parallax effect |
The repository mixes original code with third-party assets, so the licensing is not uniform:
| Part | License |
|---|---|
Source code (src/, CMakeLists.txt) |
MIT — Copyright (c) 2026 Wojciech Wypych (Iakirmon) |
| Textures, sounds and music from Kenney packs | CC0 1.0 — public domain |
assets/fonts/Roboto-Regular.ttf (Roboto 3.015) |
SIL Open Font License 1.1 — assets/fonts/OFL.txt |
| SFML | zlib/png — external dependency, not part of this repository |
MIT covers the code, not the assets. Roboto stays under OFL 1.1 and its license text is bundled with the repository, because OFL requires it on redistribution.