Commit a8f3995d authored by Сулимов Игорь Андреевич's avatar Сулимов Игорь Андреевич
Browse files

Done main lab work

parent 06c0f077
No related merge requests found
Showing with 24 additions and 7 deletions
+24 -7
......@@ -14,15 +14,19 @@ namespace config {
const char BUTTON_TEXT_EASY[] = "Easy";
const char BUTTON_TEXT_MEDIUM[] = "Medium";
const char BUTTON_TEXT_HARD[] = "Hard";
const char BUTTON_TEXT_BONUS[] = "Bonus";
const char BUTTON_TEXT_EXIT[] = "Exit";
// Игра:
const sf::VideoMode GAME_VIDEO_MODE{ 1080, 720 };
const char EASY_GAME_TITLE[] = "Level: Easy";
const char MEDIUM_GAME_TITLE[] = "Level: Medium";
const char HARD_GAME_TITLE[] = "Level: Hard";
const char BONUS_GAME_TITLE[] = "Level: Hard";
const float EASY_GAME_ENEMY_RATIO = 0.0f;
const float MEDIUM_GAME_ENEMY_RATIO = 0.03f;
const float HARD_GAME_ENEMY_RATIO = 0.07f;
const float HARD_GAME_ENEMY_RATIO = 0.05f;
const float ROOM_SIZE_EASY = 140;
const float ROOM_SIZE_MEADIUM = 70;
const float ROOM_SIZE = 50;
const float GAME_ENEMY_SIZE = ROOM_SIZE * 0.7;
const float GAME_FOOD_SIZE = ROOM_SIZE * 0.2;
......
......@@ -12,7 +12,7 @@ public:
IWindowKeeper(const sf::VideoMode& video_mode, const std::string& window_title) :
m_window(video_mode, window_title) {
m_window.setFramerateLimit(config::FRAME_RATE_LIMIT);
m_window.setKeyRepeatEnabled(false);
// m_window.setKeyRepeatEnabled(false);
}
protected:
sf::RenderWindow m_window;
......
......@@ -12,9 +12,9 @@ public:
bool do_step() override;
protected:
void process_key_pressed(sf::Keyboard::Key key);
void event_handling() override; ///@todo
void update() override {}; ///@todo
void render() override; ///@todo
void event_handling() override;
void update() override;
void render() override;
void process_entities_interactions(IVisitor* entity);
public:
GameState(IStateManager& state_manager,
......
......@@ -12,7 +12,7 @@ Menu::Menu(IStateManager& state_manager) {
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::ROOM_SIZE_EASY),
config::GAME_VIDEO_MODE,
config::EASY_GAME_TITLE,
config::EASY_GAME_ENEMY_RATIO);
......@@ -20,7 +20,7 @@ Menu::Menu(IStateManager& state_manager) {
auto medium_director = std::make_unique<GameBuilderDirector>(
std::make_unique<SimpleBuilder>(
config::GAME_VIDEO_MODE.width, config::GAME_VIDEO_MODE.height,
config::ROOM_SIZE),
config::ROOM_SIZE_MEADIUM),
config::GAME_VIDEO_MODE,
config::MEDIUM_GAME_TITLE,
config::MEDIUM_GAME_ENEMY_RATIO);
......
......@@ -86,6 +86,19 @@ void GameState::event_handling() {
}
}
void GameState::update() {
if (m_context_manager.get_current_context().state == GameContext::LOST ||
m_context_manager.get_current_context().state == GameContext::WIN) {
return;
}
for (auto& obj : m_context_manager.get_current_context().dynamic_objects) {
obj->action();
}
process_entities_interactions(&m_context_manager.get_current_context().pacman);
if (!m_context_manager.get_current_context().static_objects.size())
m_context_manager.get_current_context().state = GameContext::WIN;
}
void GameState::render() {
if (m_context_manager.get_current_context().state == GameContext::INGAME) {
m_window.clear(config::GAME_COLOR_BACKGROUND_INGAME);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment