diff --git a/assets/README.md b/assets/README.md new file mode 100644 index 0000000..0197588 --- /dev/null +++ b/assets/README.md @@ -0,0 +1,16 @@ +# Asset Credits & Attribution + +The multimedia resources (graphics, sprites, and audio files) contained within this folder are not my personal creations. They have been curated and adapted from the open-source community for educational development. + +## Original Source Information +* **Project:** Moddable Pong +* **Author / Creator:** Endless OS Foundation & Endless Studios +* **Website:** [endlessos.org](https://endlessos.org) +* **Source Code Repository:** [github.com/endlessm/moddable-pong](https://github.com/endlessm/moddable-pong/) + +--- + +## Usage Notice +These assets are integrated strictly for non-commercial, academic layout validation and development milestones. This work is part of a student engineering project within the **Helios Additional_activity** initiative at the **Technical University of Cluj-Napoca (UTCN) - Faculty of Electronics, Telecommunications and Information Technology (ETTI)**. + +All rights, ownership, and copyrights belong entirely to the original creators at the Endless OS Foundation. \ No newline at end of file diff --git a/assets/audio/banana_wall_hit.ogg b/assets/audio/banana_wall_hit.ogg new file mode 100644 index 0000000..232e63f Binary files /dev/null and b/assets/audio/banana_wall_hit.ogg differ diff --git a/assets/audio/paddle_hit.ogg b/assets/audio/paddle_hit.ogg new file mode 100644 index 0000000..692386d Binary files /dev/null and b/assets/audio/paddle_hit.ogg differ diff --git a/assets/audio/score.ogg b/assets/audio/score.ogg new file mode 100644 index 0000000..66858bd Binary files /dev/null and b/assets/audio/score.ogg differ diff --git a/assets/audio/wall_hit.ogg b/assets/audio/wall_hit.ogg new file mode 100644 index 0000000..af3b1e3 Binary files /dev/null and b/assets/audio/wall_hit.ogg differ diff --git a/assets/textures/ball/basic_ball_5.png b/assets/textures/ball/basic_ball_5.png new file mode 100644 index 0000000..fcd7fc2 Binary files /dev/null and b/assets/textures/ball/basic_ball_5.png differ diff --git a/assets/textures/hud/line.png b/assets/textures/hud/line.png new file mode 100644 index 0000000..9ce5b41 Binary files /dev/null and b/assets/textures/hud/line.png differ diff --git a/assets/textures/paddles/basic_paddle.png b/assets/textures/paddles/basic_paddle.png new file mode 100644 index 0000000..3ea6181 Binary files /dev/null and b/assets/textures/paddles/basic_paddle.png differ diff --git a/assets/textures/paddles/basic_paddle_2.png b/assets/textures/paddles/basic_paddle_2.png new file mode 100644 index 0000000..ef603d2 Binary files /dev/null and b/assets/textures/paddles/basic_paddle_2.png differ diff --git a/assets/textures/spaces/asteroid.png b/assets/textures/spaces/asteroid.png new file mode 100644 index 0000000..2db0d29 Binary files /dev/null and b/assets/textures/spaces/asteroid.png differ diff --git a/assets/textures/spaces/basic_space.png b/assets/textures/spaces/basic_space.png new file mode 100644 index 0000000..2c44d17 Binary files /dev/null and b/assets/textures/spaces/basic_space.png differ diff --git a/assets/textures/spaces/galaxy_space.png b/assets/textures/spaces/galaxy_space.png new file mode 100644 index 0000000..6bec620 Binary files /dev/null and b/assets/textures/spaces/galaxy_space.png differ diff --git a/assets/textures/spaces/trap_space.png b/assets/textures/spaces/trap_space.png new file mode 100644 index 0000000..7842c0c Binary files /dev/null and b/assets/textures/spaces/trap_space.png differ diff --git a/assets/textures/spaces/vortex.png b/assets/textures/spaces/vortex.png new file mode 100644 index 0000000..7820908 Binary files /dev/null and b/assets/textures/spaces/vortex.png differ diff --git a/assets/textures/spaces/walls.png b/assets/textures/spaces/walls.png new file mode 100644 index 0000000..d6bfdc9 Binary files /dev/null and b/assets/textures/spaces/walls.png differ diff --git a/include/game.h b/include/game.h index 89fc394..e1d8981 100644 --- a/include/game.h +++ b/include/game.h @@ -7,6 +7,7 @@ // Game States & Configurations enum class GameState { MainMenu, + DifficultySelect, Playing, Paused, GameOver @@ -28,8 +29,6 @@ class GameObject { public: Vector2 position; Color color; - -public: GameObject(Vector2 pos, Color c) : position(pos), color(c) {} virtual ~GameObject() = default; diff --git a/include/menu.h b/include/menu.h index 3535800..07c247d 100644 --- a/include/menu.h +++ b/include/menu.h @@ -16,6 +16,6 @@ public: : title(menuTitle), options(menuOptions), selectedIndex(0) { } - void Update(GameState& currentState); + int Update(); void Draw(); }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 9db3151..dc67d11 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,6 +48,7 @@ int main() { GameState currentState = GameState::MainMenu; Menu mainMenu("PONG RELOADED", { "Start Game", "Quit" }); + Menu difficultyMenu("SELECT DIFFICULTY", { "Easy", "Normal", "Hard", "Back" }); // --- Main Game Loop --- @@ -58,11 +59,44 @@ int main() { switch (currentState) { case GameState::MainMenu: { - mainMenu.Update(currentState); + int selected = mainMenu.Update(); + if (selected == 0) { + currentState = GameState::DifficultySelect; + } + else if (selected == 1) { + currentState = GameState::GameOver; + } mainMenu.Draw(); break; } + case GameState::DifficultySelect: + { + int selected = difficultyMenu.Update(); + if (selected >= 0 && selected <= 2) { + if (selected == 0) { + cpu.SetDifficulty(Difficulty::Easy); + } + else if (selected == 1) { + cpu.SetDifficulty(Difficulty::Normal); + } + else if (selected == 2) { + cpu.SetDifficulty(Difficulty::Hard); + } + + // Reset game session stats + player_score = 0; + cpu_score = 0; + ResetBall(ball, screen_width, screen_height); + currentState = GameState::Playing; + } + else if (selected == 3) { + currentState = GameState::MainMenu; + } + difficultyMenu.Draw(); + break; + } + case GameState::Playing: { ball.Update(); diff --git a/src/menu.cpp b/src/menu.cpp index 4d18b90..657548b 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -1,25 +1,21 @@ #include "menu.h" -void Menu::Update(GameState& currentState) { +int Menu::Update() { // Handle Navigation if (IsKeyPressed(KEY_DOWN)) { selectedIndex++; - if (selectedIndex >= options.size()) selectedIndex = 0; + if (selectedIndex >= static_cast(options.size())) selectedIndex = 0; } if (IsKeyPressed(KEY_UP)) { selectedIndex--; - if (selectedIndex < 0) selectedIndex = options.size() - 1; + if (selectedIndex < 0) selectedIndex = static_cast(options.size()) - 1; } // Handle Selection if (IsKeyPressed(KEY_ENTER)) { - if (options[selectedIndex] == "Start Game") { - currentState = GameState::Playing; - } - else if (options[selectedIndex] == "Quit") { - currentState = GameState::GameOver; - } + return selectedIndex; } + return -1; } void Menu::Draw() { @@ -30,7 +26,7 @@ void Menu::Draw() { DrawText(title.c_str(), screenWidth / 2 - MeasureText(title.c_str(), 60) / 2, screenHeight / 4, 60, WHITE); // Draw Options - for (int i = 0; i < options.size(); i++) { + for (int i = 0; i < static_cast(options.size()); i++) { Color textColor = (i == selectedIndex) ? YELLOW : WHITE; DrawText(options[i].c_str(), screenWidth / 2 - MeasureText(options[i].c_str(), 40) / 2, screenHeight / 2 + (i * 60), 40, textColor); }