Commit f33f3ec7 authored by Ушкова Диана Петровна's avatar Ушкова Диана Петровна
Browse files

some bugs

parent 46e4655a
No related merge requests found
Showing with 17 additions and 11 deletions
+17 -11
No preview for this file type
No preview for this file type
assets/screamer.png

133 KB | W: | H:

assets/screamer.png

3.28 MB | W: | H:

assets/screamer.png
assets/screamer.png
assets/screamer.png
assets/screamer.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -29,5 +29,5 @@ private:
sf::Sprite m_sprite;
sf::Sound m_sound;
MyTexture* m_ptr_texture;
bool m_second_player;
bool m_second_player = false;
};
......@@ -44,6 +44,8 @@ void PacmanLoseLifeEvent::handle(GameContext *context) {
pacman_lose_life.lose_life();
if (pacman_lose_life.died()) {
if (context->pacman.died() && !m_second_player && context->pacman2.get_lives() == 3)
context->state = GameContext::LOST;
if (context->pacman.died() && context->pacman2.died())
context->state = GameContext::LOST;
}
......
......@@ -63,18 +63,20 @@ bool GameState::process_key_pressed(sf::Keyboard::Key code) {
GameContext& context = m_context_manager.get_current_context();
if (code == sf::Keyboard::W || code == sf::Keyboard::A || code == sf::Keyboard::S || code == sf::Keyboard::D) {
m_context_manager.save_current_context();
switch (code) {
case config::KEY_UP: context.pacman.move(Room::UP); break;
case config::KEY_DOWN: context.pacman.move(Room::DOWN); break;
case config::KEY_LEFT: context.pacman.move(Room::LEFT); break;
case config::KEY_RIGHT: context.pacman.move(Room::RIGHT); break;
if (context.pacman.get_lives() > 0) {
m_context_manager.save_current_context();
switch (code) {
case config::KEY_UP: context.pacman.move(Room::UP); break;
case config::KEY_DOWN: context.pacman.move(Room::DOWN); break;
case config::KEY_LEFT: context.pacman.move(Room::LEFT); break;
case config::KEY_RIGHT: context.pacman.move(Room::RIGHT); break;
}
return true;
}
return true;
}
if (code == sf::Keyboard::Up || code == sf::Keyboard::Down || code == sf::Keyboard::Left || code == sf::Keyboard::Right) {
if (context.pacman2.get_location() != nullptr) {
if (context.pacman2.get_location() != nullptr && context.pacman2.get_lives() > 0) {
m_context_manager.save_current_context();
switch (code) {
case sf::Keyboard::Up: context.pacman2.move(Room::UP); break;
......@@ -215,6 +217,10 @@ void GameState::render() {
m_menu.draw_hearts(m_window, context.pacman.get_lives(), 0.f);
m_maze.draw_into(m_window);
for (auto& obj : context.static_objects)
obj->draw_into(m_window);
if (context.pacman.get_lives() > 0)
context.pacman.draw_into(m_window);
......@@ -223,8 +229,6 @@ void GameState::render() {
context.pacman2.draw_into(m_window);
}
for (auto& obj : context.static_objects)
obj->draw_into(m_window);
for (auto& el : context.dynamic_objects)
el->draw_into(m_window);
......
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