From 0bbe00fe019465abfd7196f1da66c0c0de58b67b Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Thu, 13 Nov 2025 14:35:12 -0500 Subject: [PATCH] add ghost specific classes and temporarily remove sound --- CMakeLists.txt | 4 ++-- src/Blinky.cpp | 5 +++++ src/Blinky.h | 11 +++++++++++ src/Clyde.cpp | 5 +++++ src/Clyde.h | 11 +++++++++++ src/Game.cpp | 20 ++++++++++++-------- src/Ghost.h | 6 +++++- src/Inky.cpp | 5 +++++ src/Inky.h | 11 +++++++++++ src/Pinky.cpp | 5 +++++ src/Pinky.h | 11 +++++++++++ 11 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 src/Blinky.cpp create mode 100644 src/Blinky.h create mode 100644 src/Clyde.cpp create mode 100644 src/Clyde.h create mode 100644 src/Inky.cpp create mode 100644 src/Inky.h create mode 100644 src/Pinky.cpp create mode 100644 src/Pinky.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fa88ca..e744090 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ FetchContent_Declare(json FetchContent_MakeAvailable(SFML json) -add_executable(main src/main.cpp src/Entity.cpp src/Game.cpp src/MazeMap.cpp src/ResourceManager.cpp) +add_executable(main src/main.cpp src/Entity.cpp src/Game.cpp src/MazeMap.cpp src/ResourceManager.cpp src/Blinky.cpp src/Pinky.cpp src/Inky.cpp src/Clyde.cpp) target_compile_features(main PRIVATE cxx_std_17) target_link_libraries(main PRIVATE SFML::Graphics SFML::Audio nlohmann_json::nlohmann_json) @@ -28,4 +28,4 @@ add_custom_command(TARGET main POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/assets ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assets - COMMENT "Copying assets to build directory") \ No newline at end of file + COMMENT "Copying assets to build directory") diff --git a/src/Blinky.cpp b/src/Blinky.cpp new file mode 100644 index 0000000..d434580 --- /dev/null +++ b/src/Blinky.cpp @@ -0,0 +1,5 @@ +#include "Blinky.h" + +void Blinky::setTargetTile() { + +}; diff --git a/src/Blinky.h b/src/Blinky.h new file mode 100644 index 0000000..a736086 --- /dev/null +++ b/src/Blinky.h @@ -0,0 +1,11 @@ +#ifndef BLINKY_H +#define BLINKY_H + +#include "Ghost.h" + +class Blinky : public Ghost { +public: + void setTargetTile() override; +}; + +#endif diff --git a/src/Clyde.cpp b/src/Clyde.cpp new file mode 100644 index 0000000..1c5c2b0 --- /dev/null +++ b/src/Clyde.cpp @@ -0,0 +1,5 @@ +#include "Clyde.h" + +void Clyde::setTargetTile() { + +}; diff --git a/src/Clyde.h b/src/Clyde.h new file mode 100644 index 0000000..ce54e59 --- /dev/null +++ b/src/Clyde.h @@ -0,0 +1,11 @@ +#ifndef CLYDE_H +#define CLYDE_H + +#include "Ghost.h" + +class Clyde : public Ghost { +public: + void setTargetTile() override; +}; + +#endif diff --git a/src/Game.cpp b/src/Game.cpp index b9135e7..87e9748 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -8,7 +8,11 @@ #include #include "Game.h" +#include "Blinky.h" +#include "Clyde.h" +#include "Inky.h" #include "MazeMap.h" +#include "Pinky.h" #include "ResourceManager.h" #include "Pacman.h" #include "Ghost.h" @@ -91,10 +95,10 @@ void Game::run() { Pacman pacman; - Ghost blinky; - Ghost pinky; - Ghost inky; - Ghost clyde; + Blinky blinky; + Pinky pinky; + Inky inky; + Clyde clyde; pacman.setAnimationTiles(resources.getTexture("all_textures"), {1824, 0}, "right_walking", {60, 60}, 2, 0); pacman.setAnimationTiles(resources.getTexture("all_textures"), {1824, 64}, "left_walking", {60, 60}, 2, 0); @@ -143,7 +147,7 @@ void Game::run() { auto window = sf::RenderWindow(sf::VideoMode(windowRes), windowName); sf::Sound sound(*resources.getSound("start")); - sound.play(); + //sound.play(); sf::Sound pellet0(*resources.getSound("eat_dot_0")); sf::Sound pellet1(*resources.getSound("eat_dot_1")); @@ -339,16 +343,16 @@ void Game::run() { break; case PelletType::ENERGIZER: score += 50; - fright.play(); + //fright.play(); break; }; scoreText.setString(std::to_string(score)); if (pelletSoundCount % 2) { - pellet1.play(); + //pellet1.play(); } else { - pellet0.play(); + //pellet0.play(); } pelletSoundCount++; diff --git a/src/Ghost.h b/src/Ghost.h index ac40815..562eff9 100644 --- a/src/Ghost.h +++ b/src/Ghost.h @@ -2,9 +2,13 @@ #define GHOST_H #include "Entity.h" +#include class Ghost : public Entity { - +public: + virtual void setTargetTile() = 0; +protected: + sf::Vector2i targetTile; }; #endif diff --git a/src/Inky.cpp b/src/Inky.cpp new file mode 100644 index 0000000..37c6055 --- /dev/null +++ b/src/Inky.cpp @@ -0,0 +1,5 @@ +#include "Inky.h" + +void Inky::setTargetTile() { + +}; diff --git a/src/Inky.h b/src/Inky.h new file mode 100644 index 0000000..04e77d3 --- /dev/null +++ b/src/Inky.h @@ -0,0 +1,11 @@ +#ifndef INKY_H +#define INKY_H + +#include "Ghost.h" + +class Inky : public Ghost { +public: + void setTargetTile() override; +}; + +#endif diff --git a/src/Pinky.cpp b/src/Pinky.cpp new file mode 100644 index 0000000..472cea7 --- /dev/null +++ b/src/Pinky.cpp @@ -0,0 +1,5 @@ +#include "Pinky.h" + +void Pinky::setTargetTile() { + +}; diff --git a/src/Pinky.h b/src/Pinky.h new file mode 100644 index 0000000..a4adf20 --- /dev/null +++ b/src/Pinky.h @@ -0,0 +1,11 @@ +#ifndef PINKY_H +#define PINKY_H + +#include "Ghost.h" + +class Pinky : public Ghost { +public: + void setTargetTile() override; +}; + +#endif