Source

Target

Commits (2)
Showing with 546 additions and 50 deletions
+546 -50
...@@ -24,11 +24,13 @@ add_executable(pacman source/main.cpp ...@@ -24,11 +24,13 @@ add_executable(pacman source/main.cpp
"source/State/States.cpp" "source/State/States.cpp"
"source/State/SelectState.cpp" "source/State/SelectState.cpp"
"source/Event/IGameEvent.cpp" "source/Event/IGameEvent.cpp"
"source/Draw/Texture.cpp" "source/Event/Sound.h" "source/Event/Sound.cpp") "source/Draw/Texture.cpp"
"source/Event/Sound.cpp")
target_link_libraries(pacman PRIVATE sfml-window sfml-graphics sfml-system sfml-audio ${OpenCV_LIBS}) target_link_libraries(pacman PRIVATE sfml-window sfml-graphics sfml-system sfml-audio ${OpenCV_LIBS})
target_compile_definitions(pacman PRIVATE FONT_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Fonts/pixel.ttf") target_compile_definitions(pacman PRIVATE FONT_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Fonts/pixel.ttf")
target_compile_definitions(pacman PRIVATE BAR_FONT_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Fonts/bar.ttf")
target_compile_definitions(pacman PRIVATE TEXTURE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Textures/") target_compile_definitions(pacman PRIVATE TEXTURE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Textures/")
target_compile_definitions(pacman PRIVATE VIDEO_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Video/") target_compile_definitions(pacman PRIVATE VIDEO_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Video/")
target_compile_definitions(pacman PRIVATE SOUND_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Sound/") target_compile_definitions(pacman PRIVATE SOUND_PATH="${CMAKE_CURRENT_SOURCE_DIR}/source/Assets/Sound/")
......
...@@ -7,7 +7,6 @@ class Application : public IStateManager { ...@@ -7,7 +7,6 @@ class Application : public IStateManager {
private: private:
std::unique_ptr<IState> m_ptr_state_current; std::unique_ptr<IState> m_ptr_state_current;
std::unique_ptr<IState> m_ptr_state_next; std::unique_ptr<IState> m_ptr_state_next;
private: private:
void apply_deferred_state_change(); void apply_deferred_state_change();
void set_next_state(std::unique_ptr<IState>&& state) override; void set_next_state(std::unique_ptr<IState>&& state) override;
......
...@@ -16,26 +16,33 @@ std::unique_ptr<GameState> GameBuilderDirector::build(IStateManager& state_manag ...@@ -16,26 +16,33 @@ std::unique_ptr<GameState> GameBuilderDirector::build(IStateManager& state_manag
return m_ptr_builder->get_game(); return m_ptr_builder->get_game();
} }
//std::unique_ptr<TutorState> GameBuilderDirector::build_t(IStateManager& state_manager) {
// m_ptr_builder->create_rooms();
// m_ptr_builder->set_rooms_sides();
// m_ptr_builder->create_context(m_dynamic_obj_ratio);
// m_ptr_builder->create_state(state_manager, m_mode, m_window_title);
// m_ptr_builder->set_all_to_state();
// return m_ptr_builder->get_game_t();
//}
void CommonBuilder::create_context(float dynamic_object_ratio) { void CommonBuilder::create_context(float dynamic_object_ratio) {
std::vector<Room*> buf; std::vector<Room*> buf;
for (auto& row : m_rooms) { for (auto& row : m_rooms) {
for (auto& room : row) { for (auto& room : row) {
if (room != nullptr) { // ( create rooms) if (room != nullptr) {
buf.emplace_back(room); buf.emplace_back(room.get());
} }
} }
} }
srand(time(NULL));
//
int pos = std::rand() % buf.size(); int pos = std::rand() % buf.size();
m_context.pacman.set_location(buf.at(pos)); m_context.pacman.set_location(buf.at(pos));
auto iter = buf.begin() + pos; auto iter = buf.begin() + pos;
buf.erase(iter); buf.erase(iter);
// size_t rooms_in_row = static_cast<size_t>(m_width / m_room_size);
size_t rooms_in_row = static_cast<size_t>(m_width / m_room_size); //
size_t rooms_in_col = static_cast<size_t>(m_height / m_room_size); size_t rooms_in_col = static_cast<size_t>(m_height / m_room_size);
for (size_t i = 0; i < static_cast<size_t>(rooms_in_row * rooms_in_col * dynamic_object_ratio); ++i) { for (size_t i = 0; i < static_cast<size_t>(rooms_in_row * rooms_in_col * dynamic_object_ratio); ++i) {
pos = std::rand() % buf.size(); pos = std::rand() % buf.size();
...@@ -44,11 +51,9 @@ void CommonBuilder::create_context(float dynamic_object_ratio) { ...@@ -44,11 +51,9 @@ void CommonBuilder::create_context(float dynamic_object_ratio) {
iter = buf.begin() + pos; iter = buf.begin() + pos;
buf.erase(iter); buf.erase(iter);
} }
//
for (size_t i = 0; i < buf.size(); ++i) { for (size_t i = 0; i < buf.size(); ++i) {
size_t choise = rand() % 1000; size_t choise = rand() % 1000;
if (choise >= config::POTION_RATE) { if (choise >= config::POTION_RATE) {
...@@ -64,15 +69,18 @@ void CommonBuilder::create_context(float dynamic_object_ratio) { ...@@ -64,15 +69,18 @@ void CommonBuilder::create_context(float dynamic_object_ratio) {
void CommonBuilder::create_state(IStateManager& state_manager, const sf::VideoMode& mode, const std::string& window_title) { void CommonBuilder::create_state(IStateManager& state_manager, const sf::VideoMode& mode, const std::string& window_title) {
m_game_state = std::make_unique<GameState>(state_manager, mode, window_title); m_game_state = std::make_unique<GameState>(state_manager, mode, window_title);
//m_tutor_state = std::make_unique<TutorState>(state_manager, mode, window_title);
} }
std::unique_ptr<GameState> CommonBuilder::get_game() { std::unique_ptr<GameState> CommonBuilder::get_game() {
return std::move(m_game_state); return std::move(m_game_state);
} }
//std::unique_ptr<TutorState> CommonBuilder::get_game_t() {
// return std::move(m_tutor_state);
//}
void CommonBuilder::set_all_to_state() { void CommonBuilder::set_all_to_state() {
std::vector<std::unique_ptr<Room>> rooms; std::vector<std::unique_ptr<Room>> rooms;
for (auto& row : m_rooms) { // unique for (auto& row : m_rooms) {
for (auto& room : row) { for (auto& room : row) {
rooms.emplace_back(std::move(room)); rooms.emplace_back(std::move(room));
} }
...@@ -87,13 +95,13 @@ void SimpleBuilder::create_rooms() { ...@@ -87,13 +95,13 @@ void SimpleBuilder::create_rooms() {
m_rooms_in_row = static_cast<size_t>(m_width / m_room_size); m_rooms_in_row = static_cast<size_t>(m_width / m_room_size);
m_rooms_in_col = static_cast<size_t>(m_height / m_room_size); m_rooms_in_col = static_cast<size_t>(m_height / m_room_size);
float top_gap = (m_height - m_rooms_in_col * m_room_size) / 2 + m_room_size / 2; //+m_room_size/2 - setorigin float top_gap = (m_height - m_rooms_in_col * m_room_size) / 2 + m_room_size / 2;
float left_gap = (m_width - m_rooms_in_row * m_room_size) / 2 + m_room_size / 2; float left_gap = (m_width - m_rooms_in_row * m_room_size) / 2 + m_room_size / 2;
for (size_t i = 0; i < m_rooms_in_col; ++i) { for (size_t i = 0; i < m_rooms_in_col; ++i) {
std::vector<Room*> row; std::vector<std::unique_ptr<Room>> row;
for (size_t j = 0; j < m_rooms_in_row; ++j) { for (size_t j = 0; j < m_rooms_in_row; ++j) {
Room* room = new Room(m_room_size); auto room = std::make_unique<Room>(m_room_size);
room->set_position({ left_gap + m_room_size * j, top_gap + m_room_size * i }); room->set_position({ left_gap + m_room_size * j, top_gap + m_room_size * i });
row.emplace_back(std::move(room)); row.emplace_back(std::move(room));
} }
...@@ -169,17 +177,17 @@ ComplexBuilder::ComplexBuilder(float width, float height, float room_size) : Com ...@@ -169,17 +177,17 @@ ComplexBuilder::ComplexBuilder(float width, float height, float room_size) : Com
void ComplexBuilder::create_rooms() { void ComplexBuilder::create_rooms() {
m_rooms_in_row = static_cast<size_t>(m_width / m_room_size); m_rooms_in_row = static_cast<size_t>(m_width / m_room_size);
m_rooms_in_col = static_cast<size_t>(m_height / m_room_size); m_rooms_in_col = static_cast<size_t>(m_height / m_room_size);
m_rooms_in_row = m_rooms_in_row - ((m_rooms_in_row + 1) % 2); // rooms_in_row - , ( ) m_rooms_in_row = m_rooms_in_row - ((m_rooms_in_row + 1) % 2);
m_rooms_in_col = m_rooms_in_col - ((m_rooms_in_col + 1) % 2); m_rooms_in_col = m_rooms_in_col - ((m_rooms_in_col + 1) % 2);
float top_gap = (m_height - m_rooms_in_col * m_room_size) / 2 + m_room_size / 2; float top_gap = (m_height - m_rooms_in_col * m_room_size) / 2 + m_room_size / 2;
float left_gap = (m_width - m_rooms_in_row * m_room_size) / 2 + m_room_size / 2; float left_gap = (m_width - m_rooms_in_row * m_room_size) / 2 + m_room_size / 2;
for (size_t i = 0; i < m_rooms_in_col; ++i) { for (size_t i = 0; i < m_rooms_in_col; ++i) {
std::vector<Room*> row; std::vector<std::unique_ptr<Room>> row;
for (size_t j = 0; j < m_rooms_in_row; ++j) { for (size_t j = 0; j < m_rooms_in_row; ++j) {
if (i % 2 == 0 && j % 2 == 0) { continue; } if (i % 2 == 0 && j % 2 == 0) { continue; }
Room* room = new Room(m_room_size); auto room = std::make_unique<Room>(m_room_size);
room->set_position({ left_gap + m_room_size * j, top_gap + m_room_size * i }); room->set_position({ left_gap + m_room_size * j, top_gap + m_room_size * i });
row.emplace_back(std::move(room)); row.emplace_back(std::move(room));
} }
......
...@@ -12,6 +12,7 @@ public: ...@@ -12,6 +12,7 @@ public:
virtual void create_state(IStateManager& state_manager, const sf::VideoMode& mode, const std::string& window_title) = 0; virtual void create_state(IStateManager& state_manager, const sf::VideoMode& mode, const std::string& window_title) = 0;
virtual void set_all_to_state() = 0; virtual void set_all_to_state() = 0;
virtual std::unique_ptr<GameState> get_game() = 0; virtual std::unique_ptr<GameState> get_game() = 0;
//virtual std::unique_ptr<TutorState> get_game_t() = 0;
virtual ~IGameBuilder() = default; virtual ~IGameBuilder() = default;
}; };
...@@ -24,6 +25,7 @@ private: ...@@ -24,6 +25,7 @@ private:
public: public:
GameBuilderDirector(std::unique_ptr<IGameBuilder>&& ptr_builder, const sf::VideoMode& mode, const std::string& window_title, float dynamic_objects_ratio); GameBuilderDirector(std::unique_ptr<IGameBuilder>&& ptr_builder, const sf::VideoMode& mode, const std::string& window_title, float dynamic_objects_ratio);
std::unique_ptr<GameState> build(IStateManager& state_manager); std::unique_ptr<GameState> build(IStateManager& state_manager);
//std::unique_ptr<TutorState> build_t(IStateManager& state_manager);
}; };
class CommonBuilder :public IGameBuilder { class CommonBuilder :public IGameBuilder {
...@@ -33,15 +35,18 @@ protected: ...@@ -33,15 +35,18 @@ protected:
float m_room_size; float m_room_size;
size_t m_rooms_in_row; size_t m_rooms_in_row;
size_t m_rooms_in_col; size_t m_rooms_in_col;
std::vector<std::vector<Room*>> m_rooms; std::vector<std::vector<std::unique_ptr<Room>>> m_rooms;
private: private:
GameContext m_context; GameContext m_context;
std::unique_ptr<GameState> m_game_state; std::unique_ptr<GameState> m_game_state;
//std::unique_ptr<TutorState> m_tutor_state;
public: public:
CommonBuilder(float width, float height, float room_size) : m_height(height), m_width(width), m_room_size(room_size) {} CommonBuilder(float width, float height, float room_size) : m_height(height), m_width(width), m_room_size(room_size) {}
void create_context(float dynamic_object_ratio) override; void create_context(float dynamic_object_ratio) override;
void create_state(IStateManager& state_manager, const sf::VideoMode& mode, const std::string& window_title) override; void create_state(IStateManager& state_manager, const sf::VideoMode& mode, const std::string& window_title) override;
std::unique_ptr<GameState> get_game() override; std::unique_ptr<GameState> get_game() override;
//std::unique_ptr<TutorState> get_game_t() override;
void set_all_to_state() override; void set_all_to_state() override;
}; };
......
#include "ChangeStateCommand.h" #include "ChangeStateCommand.h"
#include "../State/States.h" #include "../State/States.h"
#include "../State/SelectState.h"
void ExitCommand::execute() { void ExitCommand::execute() {
m_state_manager.set_next_state(std::make_unique<ExitState>(m_state_manager)); m_state_manager.set_next_state(std::make_unique<ExitState>(m_state_manager));
} }
...@@ -8,4 +9,15 @@ void ExitCommand::execute() { ...@@ -8,4 +9,15 @@ void ExitCommand::execute() {
void GameCommand::execute() { void GameCommand::execute() {
std::unique_ptr<GameState> state = m_ptr_director->build(m_state_manager); std::unique_ptr<GameState> state = m_ptr_director->build(m_state_manager);
m_state_manager.set_next_state(std::move(state)); m_state_manager.set_next_state(std::move(state));
} }
\ No newline at end of file
//void CloseCommand::execute() {
// SelectState::tutor_flag = false;
// m_state_manager.set_next_state(std::make_unique<SelectState>(m_state_manager, config::SELECT_LEVEL_VIDEO_MODE, config::SELECT_LEVEL_TITLE));
//}
//
//void TutorCommand::execute() {
// SelectState::tutor_flag = false;
// std::unique_ptr<TutorState> state = m_ptr_director->build_t(m_state_manager);
// m_state_manager.set_next_state(std::move(state));
//}
\ No newline at end of file
...@@ -22,10 +22,23 @@ class ExitCommand : public ChangeStateCommand { ...@@ -22,10 +22,23 @@ class ExitCommand : public ChangeStateCommand {
void execute() override; void execute() override;
}; };
//class CloseCommand : public ChangeStateCommand {
// using ChangeStateCommand::ChangeStateCommand;
// void execute() override;
//};
class GameCommand : public ChangeStateCommand { class GameCommand : public ChangeStateCommand {
public: public:
GameCommand(IStateManager& state_manager, std::unique_ptr<GameBuilderDirector>&& ptr_director): ChangeStateCommand(state_manager), m_ptr_director(std::move(ptr_director)) {}; GameCommand(IStateManager& state_manager, std::unique_ptr<GameBuilderDirector>&& ptr_director): ChangeStateCommand(state_manager), m_ptr_director(std::move(ptr_director)) {};
void execute() override; void execute() override;
private: private:
std::unique_ptr<GameBuilderDirector> m_ptr_director; std::unique_ptr<GameBuilderDirector> m_ptr_director;
}; };
\ No newline at end of file
//class TutorCommand : public ChangeStateCommand {
//public:
// TutorCommand(IStateManager& state_manager, std::unique_ptr<GameBuilderDirector>&& ptr_director) : ChangeStateCommand(state_manager), m_ptr_director(std::move(ptr_director)) {};
// void execute() override;
//private:
// std::unique_ptr<GameBuilderDirector> m_ptr_director;
//};
\ No newline at end of file
...@@ -12,16 +12,18 @@ namespace config { ...@@ -12,16 +12,18 @@ namespace config {
const float BUTTON_FRAME_THICKNESS = 3.0f; const float BUTTON_FRAME_THICKNESS = 3.0f;
const char SELECT_LEVEL_TITLE[] = "Pacman and caves"; const char SELECT_LEVEL_TITLE[] = "Pacman and caves";
const char MENU_NAME[] = "Pacman and caves"; const char MENU_NAME[] = "Pacman and caves";
const sf::VideoMode SELECT_LEVEL_VIDEO_MODE{ 1590, 924 }; const char TUTOR_NAME[] = "Enter to tutorial ?";
const sf::VideoMode SELECT_LEVEL_VIDEO_MODE{ 1080, 720 };
const char BUTTON_TEXT_EASY[] = "Easy"; const char BUTTON_TEXT_EASY[] = "Easy";
const char BUTTON_TEXT_MEDIUM[] = "Medium"; const char BUTTON_TEXT_MEDIUM[] = "Medium";
const char BUTTON_TEXT_HARD[] = "Hard"; const char BUTTON_TEXT_HARD[] = "Hard";
const char BUTTON_TEXT_EXIT[] = "Exit"; const char BUTTON_TEXT_EXIT[] = "Exit";
// : // :
const sf::VideoMode GAME_VIDEO_MODE{ 1590, 924 }; const sf::VideoMode GAME_VIDEO_MODE{ 1080, 720 };
const char EASY_GAME_TITLE[] = "Level: Easy"; const char EASY_GAME_TITLE[] = "Level: Easy";
const char MEDIUM_GAME_TITLE[] = "Level: Medium"; const char MEDIUM_GAME_TITLE[] = "Level: Medium";
const char HARD_GAME_TITLE[] = "Level: Hard"; const char HARD_GAME_TITLE[] = "Level: Hard";
const char TUTOR_TEXT[] = "Push SPACE for launch fireball: 50MP\nPush E for use ultimate skill: 70MP\nPush Q for use magnit: 100MP";
const float EASY_GAME_ENEMY_RATIO = 0.0f; const float EASY_GAME_ENEMY_RATIO = 0.0f;
const float MEDIUM_GAME_ENEMY_RATIO = 0.03f; const float MEDIUM_GAME_ENEMY_RATIO = 0.03f;
const float HARD_GAME_ENEMY_RATIO = 0.07f; const float HARD_GAME_ENEMY_RATIO = 0.07f;
...@@ -30,11 +32,12 @@ namespace config { ...@@ -30,11 +32,12 @@ namespace config {
const float GAME_FOOD_SIZE = ROOM_SIZE * 0.2; const float GAME_FOOD_SIZE = ROOM_SIZE * 0.2;
const sf::Vector2f BAR_SIZE = { 200, 15 }; const sf::Vector2f BAR_SIZE = { 200, 15 };
const float PACMAN_MAX_MP = 300; const float PACMAN_MAX_MP = 300;
const float PACMAN_START_MP = 100; const float PACMAN_START_MP = 50;
const float FIREBALL_COST = 50; const float FIREBALL_COST = 20;
const float ULTIMATE_COST = 300; const float ULTIMATE_COST = 70;
const float MP_REGEN = 1.0f/60; const float MAGNIT_COST = PACMAN_MAX_MP;
const float POTION_MP = 25; const float MP_REGEN = 2.0f/60;
const float POTION_MP = 10;
const float SPAWN_INV = 5; const float SPAWN_INV = 5;
const size_t POTION_RATE = 900; const size_t POTION_RATE = 900;
// : // :
......
...@@ -15,3 +15,18 @@ MyFont& MyFont::Instance() { ...@@ -15,3 +15,18 @@ MyFont& MyFont::Instance() {
MyFont::operator const sf::Font& () const { MyFont::operator const sf::Font& () const {
return m_font; return m_font;
} }
BarFont::BarFont() {
if (!m_font.loadFromFile(std::string(BAR_FONT_PATH))) {
throw std::runtime_error("Cannot load file");
}
}
BarFont& BarFont::Instance() {
static BarFont instance;
return instance;
}
BarFont::operator const sf::Font& () const {
return m_font;
}
\ No newline at end of file
...@@ -12,3 +12,15 @@ private: ...@@ -12,3 +12,15 @@ private:
private: private:
sf::Font m_font; sf::Font m_font;
}; };
class BarFont {
public:
BarFont(const BarFont&) = delete;
BarFont& operator = (const BarFont&) = delete;
static BarFont& Instance();
operator const sf::Font& () const;
private:
BarFont();
private:
sf::Font m_font;
};
\ No newline at end of file
...@@ -83,3 +83,16 @@ void Ultimate::handle(GameContext& context) const { ...@@ -83,3 +83,16 @@ void Ultimate::handle(GameContext& context) const {
cv::destroyAllWindows(); cv::destroyAllWindows();
m_sound.resetBuffer(); m_sound.resetBuffer();
} }
Magnit::Magnit() {
set_sound(&MagnitSound::Instance());
m_sound.setBuffer(m_ptr_sound->get_sound());
}
static void collect_all(GameContext& context) {
context.static_obj.clear();
}
void Magnit::handle(GameContext& context) const {
collect_all(context);
}
\ No newline at end of file
...@@ -55,3 +55,13 @@ private: ...@@ -55,3 +55,13 @@ private:
MySound* m_ptr_sound; MySound* m_ptr_sound;
mutable sf::Sound m_sound; mutable sf::Sound m_sound;
}; };
class Magnit : public IGameEvent {
public:
Magnit();
void handle(GameContext& context) const override;
void set_sound(MySound* ptr_sound) { m_ptr_sound = ptr_sound; }
private:
MySound* m_ptr_sound;
mutable sf::Sound m_sound;
};
...@@ -26,6 +26,14 @@ std::unique_ptr<IGameEvent> Pacman::ultimate(){ ...@@ -26,6 +26,14 @@ std::unique_ptr<IGameEvent> Pacman::ultimate(){
return {}; return {};
} }
std::unique_ptr<IGameEvent> Pacman::magnit() {
if (m_mp == config::PACMAN_MAX_MP) {
m_mp -= config::PACMAN_MAX_MP;
return std::make_unique<Magnit>();
}
return {};
}
void Pacman::draw_into(sf::RenderWindow& window) const { void Pacman::draw_into(sf::RenderWindow& window) const {
m_mp += config::MP_REGEN; m_mp += config::MP_REGEN;
if (m_mp > config::PACMAN_MAX_MP) { if (m_mp > config::PACMAN_MAX_MP) {
......
...@@ -26,6 +26,7 @@ public: ...@@ -26,6 +26,7 @@ public:
void move(Direction direction); void move(Direction direction);
void spell(); void spell();
std::unique_ptr<IGameEvent> ultimate(); std::unique_ptr<IGameEvent> ultimate();
std::unique_ptr<IGameEvent> magnit();
void draw_into(sf::RenderWindow& window) const override; void draw_into(sf::RenderWindow& window) const override;
void prepare_for_drawing() override; void prepare_for_drawing() override;
std::unique_ptr<IGameEvent> visit(Food* ptr_food) override; std::unique_ptr<IGameEvent> visit(Food* ptr_food) override;
......
...@@ -147,9 +147,9 @@ MPbar::MPbar(){ ...@@ -147,9 +147,9 @@ MPbar::MPbar(){
m_bar.setOrigin(config::BAR_SIZE.x / 2.0f, config::BAR_SIZE.y / 2.0f); m_bar.setOrigin(config::BAR_SIZE.x / 2.0f, config::BAR_SIZE.y / 2.0f);
m_bar.setPosition(config::GAME_VIDEO_MODE.width / 2.0f, 1); m_bar.setPosition(config::GAME_VIDEO_MODE.width / 2.0f, 1);
m_text.setFont(MyFont::Instance()); m_text.setFont(BarFont::Instance());
m_text.setString(std::to_string((size_t)(m_cur_mp)) + "/" + std::to_string((size_t)m_max_mp)); m_text.setString(std::to_string((size_t)(m_cur_mp)) + "/" + std::to_string((size_t)m_max_mp));
m_text.setCharacterSize(0.8*15.0f); m_text.setCharacterSize(20.0f);
m_text.setLetterSpacing(1); m_text.setLetterSpacing(1);
auto textRect = m_text.getLocalBounds(); auto textRect = m_text.getLocalBounds();
m_text.setOrigin(textRect.width / 2.0f, textRect.height / 2.0f); m_text.setOrigin(textRect.width / 2.0f, textRect.height / 2.0f);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "../Draw/MyFont.h" #include "../Draw/MyFont.h"
#include "./../Config/Config.h" #include "./../Config/Config.h"
#include "../State/SelectState.h"
Menu::Menu(IStateManager& state_manager) { Menu::Menu(IStateManager& state_manager) {
set_texture(&MenuTexture::Instance()); set_texture(&MenuTexture::Instance());
m_sprite.setTexture(m_ptr_tex->get_texture()); m_sprite.setTexture(m_ptr_tex->get_texture());
...@@ -47,6 +48,7 @@ Menu::Menu(IStateManager& state_manager) { ...@@ -47,6 +48,7 @@ Menu::Menu(IStateManager& state_manager) {
void Menu::process_mouse(sf::Vector2f pos, bool is_pressed) { void Menu::process_mouse(sf::Vector2f pos, bool is_pressed) {
//if (!SelectState::tutor_flag) {
for (auto& button : m_buttons) { for (auto& button : m_buttons) {
if (button.is_position_in(pos)) { if (button.is_position_in(pos)) {
if (is_pressed) button.push(); if (is_pressed) button.push();
...@@ -54,7 +56,10 @@ void Menu::process_mouse(sf::Vector2f pos, bool is_pressed) { ...@@ -54,7 +56,10 @@ void Menu::process_mouse(sf::Vector2f pos, bool is_pressed) {
} }
else button.unselect(); else button.unselect();
} }
//}
/*else {
m_tutor.process_mouse(pos, is_pressed);
}*/
} }
void Menu::draw_into(sf::RenderWindow& window) const { void Menu::draw_into(sf::RenderWindow& window) const {
...@@ -74,6 +79,9 @@ void Menu::draw_into(sf::RenderWindow& window) const { ...@@ -74,6 +79,9 @@ void Menu::draw_into(sf::RenderWindow& window) const {
for (const Button& ptr_button : m_buttons) { for (const Button& ptr_button : m_buttons) {
ptr_button.draw_into(window); ptr_button.draw_into(window);
} }
/*if (SelectState::tutor_flag) {
m_tutor.draw_into(window);
}*/
} }
void Menu::prepare_name(){ void Menu::prepare_name(){
...@@ -88,3 +96,55 @@ void Menu::prepare_name(){ ...@@ -88,3 +96,55 @@ void Menu::prepare_name(){
m_name.setOutlineColor(config::BUTTON_COLOR_FRAME); m_name.setOutlineColor(config::BUTTON_COLOR_FRAME);
m_name.setOutlineThickness(config::BUTTON_FRAME_THICKNESS); m_name.setOutlineThickness(config::BUTTON_FRAME_THICKNESS);
} }
//void Tutorial::prepare_name() {
// m_name.setString(std::string(config::TUTOR_NAME));
// m_name.setFont(MyFont::Instance());
// m_name.setCharacterSize(config::NAME_FONT_SIZE/3.0f);
// m_name.setLetterSpacing(1);
// auto textRect = m_name.getLocalBounds();
// m_name.setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f);
// m_name.setPosition({ config::SELECT_LEVEL_VIDEO_MODE.width / 2.f, config::SELECT_LEVEL_VIDEO_MODE.height / 2.f - 30.f });
// m_name.setFillColor(config::BUTTON_COLOR_TEXT);
// m_name.setOutlineColor(config::BUTTON_COLOR_FRAME);
// m_name.setOutlineThickness(config::BUTTON_FRAME_THICKNESS);
//}
//Tutorial::Tutorial(IStateManager& state_manager) : m_shape({2.5f*config::BUTTON_SIZE.x, 2*config::BUTTON_SIZE.y }) {
// sf::Vector2f starting_position(config::SELECT_LEVEL_VIDEO_MODE.width / 2.f, config::SELECT_LEVEL_VIDEO_MODE.height / 2.f);
// prepare_name();
//
// m_shape.setOrigin(2.5f * config::BUTTON_SIZE.x / 2.0f, config::BUTTON_SIZE.y);
// m_shape.setPosition(starting_position);
// m_shape.setFillColor({ 90, 90, 180});
// auto easy_director = std::make_unique<GameBuilderDirector>(
// std::make_unique<SimpleBuilder>(
// config::GAME_VIDEO_MODE.width, config::GAME_VIDEO_MODE.height,
// config::ROOM_SIZE),
// config::GAME_VIDEO_MODE,
// config::EASY_GAME_TITLE,
// config::EASY_GAME_ENEMY_RATIO);
//
// auto yes_command = std::make_unique<TutorCommand>(state_manager, std::move(easy_director));
// auto not_command = std::make_unique<CloseCommand>(state_manager);
// m_buttons[0].set(sf::Vector2f{ starting_position.x - config::BUTTON_SIZE.x/2.0f, starting_position.y + m_name.getLocalBounds().height}, config::BUTTON_SIZE, "YES", config::BUTTON_FONT_SIZE, std::move(yes_command));
// m_buttons[1].set(sf::Vector2f{ starting_position.x + config::BUTTON_SIZE.x/2.0f, starting_position.y + m_name.getLocalBounds().height}, config::BUTTON_SIZE, "NO", config::BUTTON_FONT_SIZE, std::move(not_command));
//}
//
//void Tutorial::process_mouse(sf::Vector2f pos, bool is_pressed) {
// for (auto& button : m_buttons) {
// if (button.is_position_in(pos)) {
// if (is_pressed) button.push();
// else button.select();
// }
// else button.unselect();
// }
//}
//
//void Tutorial::draw_into(sf::RenderWindow& window) const {
// window.draw(m_shape);
// window.draw(m_name);
// for (const Button& ptr_button : m_buttons) {
// ptr_button.draw_into(window);
// }
//}
//
...@@ -3,6 +3,21 @@ ...@@ -3,6 +3,21 @@
#include "Button.h" #include "Button.h"
#include "../Draw/Texture.h" #include "../Draw/Texture.h"
//class Tutorial : public IDrawable {
//public:
// Tutorial(IStateManager& state_manager);
// void process_mouse(sf::Vector2f pos, bool is_pressed);
// void draw_into(sf::RenderWindow& window) const override;
// void prepare_name();
//private:
// sf::RectangleShape m_shape;
// sf::Text m_name;
// std::array<Button, 2> m_buttons;
//};
class Menu : public IDrawable { class Menu : public IDrawable {
public: public:
Menu(IStateManager& state_manager); Menu(IStateManager& state_manager);
...@@ -18,4 +33,6 @@ private: ...@@ -18,4 +33,6 @@ private:
Texture* m_ptr_tex; Texture* m_ptr_tex;
sf::Text m_name; sf::Text m_name;
std::array<Button, 4> m_buttons; std::array<Button, 4> m_buttons;
}; //Tutorial m_tutor;
\ No newline at end of file };
#include "SelectState.h" #include "SelectState.h"
#include "../Draw/MyFont.h"
#include "../Config/Config.h" #include "../Config/Config.h"
SelectState::SelectState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title) : SelectState::SelectState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title) :
...@@ -38,7 +38,10 @@ void SelectState::render() { ...@@ -38,7 +38,10 @@ void SelectState::render() {
if (!font.loadFromFile(FONT_PATH)) { if (!font.loadFromFile(FONT_PATH)) {
throw 123; throw 123;
} }
sf::Text logoText("PMvedia Studio", font, 50); static sf::Text logoText;
logoText.setFont(MyFont::Instance());
logoText.setString("PMvedia Studio");
logoText.setCharacterSize(100);
logoText.setFillColor(sf::Color::White); logoText.setFillColor(sf::Color::White);
logoText.setStyle(sf::Text::Bold); logoText.setStyle(sf::Text::Bold);
auto rect = logoText.getLocalBounds(); auto rect = logoText.getLocalBounds();
......
...@@ -11,6 +11,6 @@ public: ...@@ -11,6 +11,6 @@ public:
void update() override; void update() override;
void render() override; void render() override;
private: private:
bool logo_flag = false; inline static bool logo_flag = false;
Menu m_menu; Menu m_menu;
}; };
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
#include "../Config/Config.h" #include "../Config/Config.h"
#include "../Menu/Menu.h" #include "../Menu/Menu.h"
#include "../Event/IGameEvent.h" #include "../Event/IGameEvent.h"
#include "../Draw/MyFont.h"
GameState::GameState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title) \ GameState::GameState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title) \
: IState(state_manager), IWindowKeeper(video_mode, window_title) { : IState(state_manager), IWindowKeeper(video_mode, window_title) {
set_sound(&WinSound::Instance()); set_sound_win(&WinSound::Instance());
m_sound.setBuffer(m_ptr_sound->get_sound()); m_sound_win.setBuffer(m_ptr_sound_win->get_sound());
set_sound_lose(&LostSound::Instance());
m_sound_lose.setBuffer(m_ptr_sound_lose->get_sound());
} }
bool GameState::do_step() { bool GameState::do_step() {
...@@ -28,7 +30,10 @@ void GameState::event_handling() { ...@@ -28,7 +30,10 @@ void GameState::event_handling() {
} }
if (event.type == sf::Event::KeyPressed && event.key.control && event.key.code == sf::Keyboard::Z) { if (event.type == sf::Event::KeyPressed && event.key.control && event.key.code == sf::Keyboard::Z) {
if (m_context_manager.get_context().state == GameContext::WIN) { if (m_context_manager.get_context().state == GameContext::WIN) {
m_flag = true; m_flag_win = true;
}
if (m_context_manager.get_context().state == GameContext::LOST) {
m_flag_lose = true;
} }
m_context_manager.restore_previous_context(); m_context_manager.restore_previous_context();
} }
...@@ -101,11 +106,37 @@ void GameState::render() { ...@@ -101,11 +106,37 @@ void GameState::render() {
break; break;
case GameContext::LOST: case GameContext::LOST:
m_window.clear(config::GAME_COLOR_BACKGROUND_LOST); m_window.clear(config::GAME_COLOR_BACKGROUND_LOST);
if (m_flag_lose) {
cv::VideoCapture cap(std::string(VIDEO_PATH) + "game_over_short.mp4");
if (!cap.isOpened()) {
std::cerr << "ERROR!!!!!!!!!!!!!!!!!\n" << std::endl;
}
cv::Mat frame;
cv::namedWindow("GAME OVER", cv::WINDOW_NORMAL);
cv::resizeWindow("GAME OVER", 1920, 1080);
while (true) {
if (m_sound_lose.getStatus() == 0) {
m_sound_lose.play();
}
cap >> frame;
if (frame.empty()) break;
cv::imshow("GAME OVER", frame);
if (cv::waitKey(30) == 27) break;
}
cap.release();
cv::destroyAllWindows();
m_sound_lose.stop();
m_flag_lose = false;
}
break; break;
default: default:
m_window.clear(config::GAME_COLOR_BACKGROUND_WIN); m_window.clear(config::GAME_COLOR_BACKGROUND_WIN);
if (m_flag) { if (m_flag_win) {
cv::VideoCapture cap(std::string(VIDEO_PATH) + "WIN.mp4"); cv::VideoCapture cap(std::string(VIDEO_PATH) + "WIN.mp4");
if (!cap.isOpened()) { if (!cap.isOpened()) {
...@@ -116,8 +147,8 @@ void GameState::render() { ...@@ -116,8 +147,8 @@ void GameState::render() {
cv::namedWindow("WIN", cv::WINDOW_NORMAL); cv::namedWindow("WIN", cv::WINDOW_NORMAL);
cv::resizeWindow("WIN", 1920, 1080); cv::resizeWindow("WIN", 1920, 1080);
while (true) { while (true) {
if (m_sound.getStatus() == 0) { if (m_sound_win.getStatus() == 0) {
m_sound.play(); m_sound_win.play();
} }
cap >> frame; cap >> frame;
if (frame.empty()) break; if (frame.empty()) break;
...@@ -128,8 +159,8 @@ void GameState::render() { ...@@ -128,8 +159,8 @@ void GameState::render() {
cap.release(); cap.release();
cv::destroyAllWindows(); cv::destroyAllWindows();
m_sound.stop(); m_sound_win.stop();
m_flag = false; m_flag_win = false;
} }
} }
...@@ -177,8 +208,15 @@ void GameState::process_key_pressed(sf::Keyboard::Key code) { ...@@ -177,8 +208,15 @@ void GameState::process_key_pressed(sf::Keyboard::Key code) {
break; break;
case sf::Keyboard::E: case sf::Keyboard::E:
m_context_manager.save_context(); m_context_manager.save_context();
if (m_context_manager.get_context().m_bar.m_cur_mp == config::PACMAN_MAX_MP) { if (m_context_manager.get_context().m_bar.m_cur_mp >= config::ULTIMATE_COST) {
m_events.emplace_back(m_context_manager.get_context().pacman.ultimate()); m_events.emplace_back(m_context_manager.get_context().pacman.ultimate());
m_context_manager.get_context().m_bar.use_MP(config::ULTIMATE_COST);
}
break;
case sf::Keyboard::Q:
m_context_manager.save_context();
if (m_context_manager.get_context().m_bar.m_cur_mp == config::PACMAN_MAX_MP) {
m_events.emplace_back(m_context_manager.get_context().pacman.magnit());
m_context_manager.get_context().m_bar.use_MP(config::PACMAN_MAX_MP); m_context_manager.get_context().m_bar.use_MP(config::PACMAN_MAX_MP);
} }
break; break;
...@@ -192,3 +230,248 @@ void GameState::set_maze(Maze&& maze) { ...@@ -192,3 +230,248 @@ void GameState::set_maze(Maze&& maze) {
void GameState::set_context(GameContext&& context) { void GameState::set_context(GameContext&& context) {
m_context_manager.reset(std::move(context)); m_context_manager.reset(std::move(context));
} }
static void set_text(sf::Text& text) {
text.setString(std::string(config::TUTOR_TEXT));
text.setFont(MyFont::Instance());
text.setCharacterSize(config::NAME_FONT_SIZE / 3.0f);
text.setLetterSpacing(1);
auto textRect = text.getLocalBounds();
text.setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f);
text.setPosition({ config::SELECT_LEVEL_VIDEO_MODE.width / 2.f, config::SELECT_LEVEL_VIDEO_MODE.height / 2.f - 30.f });
text.setFillColor(config::BUTTON_COLOR_TEXT);
text.setOutlineColor(config::BUTTON_COLOR_FRAME);
text.setOutlineThickness(config::BUTTON_FRAME_THICKNESS);
}
//TutorState::TutorState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title) \
// : IState(state_manager), IWindowKeeper(video_mode, window_title), m_shape({ 2.5f * config::BUTTON_SIZE.x, 2 * config::BUTTON_SIZE.y }) {
// set_sound_win(&WinSound::Instance());
// m_sound_win.setBuffer(m_ptr_sound_win->get_sound());
// set_sound_lose(&LostSound::Instance());
// m_sound_lose.setBuffer(m_ptr_sound_lose->get_sound());
// m_shape.setOrigin(2.5f * config::BUTTON_SIZE.x / 2.0f, config::BUTTON_SIZE.y);
// m_shape.setPosition(config::GAME_VIDEO_MODE.width/2.0f, config::GAME_VIDEO_MODE.height/4.0f);
// m_shape.setFillColor({ 20,20,20 });
// set_text(m_text);
//}
//
//bool TutorState::do_step() {
// event_handling();
// update();
// render();
// return true;
//}
//
//void TutorState::event_handling() {
// sf::Event event;
// while (m_window.pollEvent(event)) {
// if (event.type == sf::Event::Closed) {
// m_state_manager.set_next_state(std::make_unique<SelectState>(m_state_manager, config::SELECT_LEVEL_VIDEO_MODE, config::SELECT_LEVEL_TITLE));
// }
// if (event.type == sf::Event::KeyPressed && event.key.control && event.key.code == sf::Keyboard::Z) {
// if (m_context_manager.get_context().state == GameContext::WIN) {
// m_flag_win = true;
// }
// if (m_context_manager.get_context().state == GameContext::LOST) {
// m_flag_lose = true;
// }
// m_context_manager.restore_previous_context();
// }
// if (event.type == sf::Event::KeyPressed && m_context_manager.get_context().state == GameContext::INGAME) {
// process_key_pressed(event.key.code);
// }
// }
//}
//
//void TutorState::update() {
// if (m_context_manager.get_context().state != GameContext::INGAME) {
// return;
// }
//
// GameContext& context = m_context_manager.get_context();
//
// IVisitor* ptr_pacman = &(m_context_manager.get_context().pacman);
// for (auto& obj : context.dynamic_obj) {
// obj->action(m_context_manager.get_context().pacman.get_location());
// auto ptr_event = obj->accept(ptr_pacman);
// if (ptr_event) { m_events.emplace_back(std::move(ptr_event)); }
// }
//
// for (auto& obj : context.dynamic_obj) {
// for (auto& spell : m_context_manager.get_context().pacman.m_spells) {
// auto ptr_event = obj->accept(&spell);
// if (ptr_event) { m_events.emplace_back(std::move(ptr_event)); }
// }
// }
//
//
// for (auto& obj : context.static_obj) {
// auto ptr_event = obj->accept(ptr_pacman);
// if (ptr_event) {
// m_events.emplace_back(std::move(ptr_event));
// }
// }
//
//
// std::vector<size_t> inds;
// for (size_t i = 0; i < m_context_manager.get_context().pacman.m_spells.size(); ++i) {
// m_context_manager.get_context().pacman.m_spells[i].move();
// if (m_context_manager.get_context().pacman.m_spells[i].m_visits > 0) {
// inds.emplace_back(i);
// }
// }
// size_t shift = 0;
// for (auto& ind : inds) {
// auto iter = m_context_manager.get_context().pacman.m_spells.begin() + ind - shift;
// m_context_manager.get_context().pacman.m_spells.erase(iter);
// shift += 1;
// }
// inds.clear();
// if (context.static_obj.empty()) {
// m_events.emplace_back(std::move(std::make_unique<WinGame>()));
// }
//
// for (int i = 0; i < m_events.size(); i++) {
// m_events.at(i)->handle(m_context_manager.get_context());
// }
// m_context_manager.get_context().m_bar.regen_MP(config::MP_REGEN);
// m_events.clear();
//}
//
//void TutorState::render() {
// auto& context = m_context_manager.get_context();
// switch (context.state) {
// case GameContext::INGAME:
// m_window.clear(config::GAME_COLOR_BACKGROUND_INGAME);
// break;
// case GameContext::LOST:
// m_window.clear(config::GAME_COLOR_BACKGROUND_LOST);
// if (m_flag_lose) {
// cv::VideoCapture cap(std::string(VIDEO_PATH) + "game_over_short.mp4");
//
// if (!cap.isOpened()) {
// std::cerr << "ERROR!!!!!!!!!!!!!!!!!\n" << std::endl;
// }
//
// cv::Mat frame;
// cv::namedWindow("GAME OVER", cv::WINDOW_NORMAL);
// cv::resizeWindow("GAME OVER", 1920, 1080);
// while (true) {
// if (m_sound_lose.getStatus() == 0) {
// m_sound_lose.play();
// }
// cap >> frame;
// if (frame.empty()) break;
//
// cv::imshow("WIN", frame);
// if (cv::waitKey(30) == 27) break;
// }
//
// cap.release();
// cv::destroyAllWindows();
// m_sound_lose.stop();
// m_flag_lose = false;
// }
// break;
// default:
// m_window.clear(config::GAME_COLOR_BACKGROUND_WIN);
//
// if (m_flag_win) {
// cv::VideoCapture cap(std::string(VIDEO_PATH) + "WIN.mp4");
//
// if (!cap.isOpened()) {
// std::cerr << "ERROR!!!!!!!!!!!!!!!!!\n" << std::endl;
// }
//
// cv::Mat frame;
// cv::namedWindow("WIN", cv::WINDOW_NORMAL);
// cv::resizeWindow("WIN", 1920, 1080);
// while (true) {
// if (m_sound_win.getStatus() == 0) {
// m_sound_win.play();
// }
// cap >> frame;
// if (frame.empty()) break;
//
// cv::imshow("WIN", frame);
// if (cv::waitKey(30) == 27) break;
// }
//
// cap.release();
// cv::destroyAllWindows();
// m_sound_win.stop();
// m_flag_win = false;
// }
// }
//
// m_maze.draw_into(m_window);
//
// for (auto& el : context.static_obj)
// el->draw_into(m_window);
//
// context.pacman.draw_into(m_window);
//
// for (auto& el : context.dynamic_obj) {
// el->draw_into(m_window);
// }
//
// context.m_bar.draw_into(m_window);
// m_window.draw(m_shape);
// m_window.draw(m_text);
// m_window.display();
//}
//
//void TutorState::process_key_pressed(sf::Keyboard::Key code) {
// switch (code) {
// case sf::Keyboard::W:
// m_context_manager.save_context();
// m_context_manager.get_context().pacman.move(Direction::UP);
// break;
//
// case sf::Keyboard::S:
// m_context_manager.save_context();
// m_context_manager.get_context().pacman.move(Direction::DOWN);
// break;
//
// case sf::Keyboard::A:
// m_context_manager.save_context();
// m_context_manager.get_context().pacman.move(Direction::LEFT);
// break;
// case sf::Keyboard::D:
// m_context_manager.save_context();
// m_context_manager.get_context().pacman.move(Direction::RIGHT);
// break;
// case sf::Keyboard::Space:
// m_context_manager.save_context();
// if (m_context_manager.get_context().m_bar.m_cur_mp >= config::FIREBALL_COST) {
// m_context_manager.get_context().pacman.spell();
// m_context_manager.get_context().m_bar.use_MP(config::FIREBALL_COST);
// }
// break;
// case sf::Keyboard::E:
// m_context_manager.save_context();
// if (m_context_manager.get_context().m_bar.m_cur_mp >= config::ULTIMATE_COST) {
// m_events.emplace_back(m_context_manager.get_context().pacman.ultimate());
// m_context_manager.get_context().m_bar.use_MP(config::ULTIMATE_COST);
// }
// break;
// case sf::Keyboard::Q:
// m_context_manager.save_context();
// if (m_context_manager.get_context().m_bar.m_cur_mp == config::PACMAN_MAX_MP) {
// m_events.emplace_back(m_context_manager.get_context().pacman.magnit());
// m_context_manager.get_context().m_bar.use_MP(config::PACMAN_MAX_MP);
// }
// break;
// }
//}
//
//void TutorState::set_maze(Maze&& maze) {
// m_maze = std::move(maze);
//}
//
//void TutorState::set_context(GameContext&& context) {
// m_context_manager.reset(std::move(context));
//}
\ No newline at end of file
...@@ -7,9 +7,12 @@ ...@@ -7,9 +7,12 @@
class GameState :public IState, public IWindowKeeper { class GameState :public IState, public IWindowKeeper {
private: private:
MySound* m_ptr_sound; MySound* m_ptr_sound_win;
sf::Sound m_sound; sf::Sound m_sound_win;
bool m_flag = true; MySound* m_ptr_sound_lose;
sf::Sound m_sound_lose;
bool m_flag_win = true;
bool m_flag_lose = true;
Maze m_maze; Maze m_maze;
ContextManager m_context_manager; ContextManager m_context_manager;
std::vector<std::unique_ptr<IGameEvent>> m_events; std::vector<std::unique_ptr<IGameEvent>> m_events;
...@@ -18,7 +21,8 @@ public: ...@@ -18,7 +21,8 @@ public:
void set_maze(Maze&& maze); void set_maze(Maze&& maze);
void set_context(GameContext&& context); void set_context(GameContext&& context);
bool do_step() override; bool do_step() override;
void set_sound(MySound* ptr_sound) { m_ptr_sound = ptr_sound; } void set_sound_win(MySound* ptr_sound) { m_ptr_sound_win = ptr_sound; }
void set_sound_lose(MySound* ptr_sound) { m_ptr_sound_lose = ptr_sound; }
private: private:
void event_handling() override; void event_handling() override;
void update() override; void update() override;
...@@ -31,4 +35,32 @@ class ExitState : public IState { ...@@ -31,4 +35,32 @@ class ExitState : public IState {
public: public:
ExitState(IStateManager& state_manager) : IState(state_manager) {}; ExitState(IStateManager& state_manager) : IState(state_manager) {};
bool do_step() override { return false; } bool do_step() override { return false; }
}; };
\ No newline at end of file
//class TutorState :public IState, public IWindowKeeper {
//private:
// MySound* m_ptr_sound_win;
// sf::Sound m_sound_win;
// MySound* m_ptr_sound_lose;
// sf::Sound m_sound_lose;
// bool m_flag_win = true;
// bool m_flag_lose = true;
// Maze m_maze;
// ContextManager m_context_manager;
// std::vector<std::unique_ptr<IGameEvent>> m_events;
// sf::Text m_text;
// sf::RectangleShape m_shape;
//public:
// TutorState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title);
// void set_maze(Maze&& maze);
// void set_context(GameContext&& context);
// bool do_step() override;
// void set_sound_win(MySound* ptr_sound) { m_ptr_sound_win = ptr_sound; }
// void set_sound_lose(MySound* ptr_sound) { m_ptr_sound_lose = ptr_sound; }
//private:
// void event_handling() override;
// void update() override;
// void render() override;
// void process_key_pressed(sf::Keyboard::Key code);
//};
\ No newline at end of file