add ghost specific classes and temporarily remove sound

This commit is contained in:
2025-11-13 14:35:12 -05:00
parent d02dfbe7b4
commit 0bbe00fe01
11 changed files with 83 additions and 11 deletions
+2 -2
View File
@@ -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")
COMMENT "Copying assets to build directory")
+5
View File
@@ -0,0 +1,5 @@
#include "Blinky.h"
void Blinky::setTargetTile() {
};
+11
View File
@@ -0,0 +1,11 @@
#ifndef BLINKY_H
#define BLINKY_H
#include "Ghost.h"
class Blinky : public Ghost {
public:
void setTargetTile() override;
};
#endif
+5
View File
@@ -0,0 +1,5 @@
#include "Clyde.h"
void Clyde::setTargetTile() {
};
+11
View File
@@ -0,0 +1,11 @@
#ifndef CLYDE_H
#define CLYDE_H
#include "Ghost.h"
class Clyde : public Ghost {
public:
void setTargetTile() override;
};
#endif
+12 -8
View File
@@ -8,7 +8,11 @@
#include <stdexcept>
#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++;
+5 -1
View File
@@ -2,9 +2,13 @@
#define GHOST_H
#include "Entity.h"
#include <SFML/System/Vector2.hpp>
class Ghost : public Entity {
public:
virtual void setTargetTile() = 0;
protected:
sf::Vector2i targetTile;
};
#endif
+5
View File
@@ -0,0 +1,5 @@
#include "Inky.h"
void Inky::setTargetTile() {
};
+11
View File
@@ -0,0 +1,11 @@
#ifndef INKY_H
#define INKY_H
#include "Ghost.h"
class Inky : public Ghost {
public:
void setTargetTile() override;
};
#endif
+5
View File
@@ -0,0 +1,5 @@
#include "Pinky.h"
void Pinky::setTargetTile() {
};
+11
View File
@@ -0,0 +1,11 @@
#ifndef PINKY_H
#define PINKY_H
#include "Ghost.h"
class Pinky : public Ghost {
public:
void setTargetTile() override;
};
#endif