Combat Mode is more reliable now, just one little glitch that it doesn't exit on the last enemy dying.

This commit is contained in:
Zed A. Shaw 2025-02-16 18:31:31 -05:00
parent 232c994347
commit cfe56bbf99
5 changed files with 20 additions and 6 deletions

View file

@ -1,4 +1,4 @@
# The Artisinal Handcrafted Retro-Future "3D" Dungeon Crawler # The Artisanal Handcrafted Retro-Future "3D" Dungeon Crawler
Welcome to my latest obsession, and turn based dungeon crawler in the style of old school raycasted Welcome to my latest obsession, and turn based dungeon crawler in the style of old school raycasted
games like _Wizardry_, _Might and Magic_, _Ultima_, and similar games. The game uses SFML 3.x as games like _Wizardry_, _Might and Magic_, _Ultima_, and similar games. The game uses SFML 3.x as

View file

@ -3,7 +3,7 @@
namespace Events { namespace Events {
enum GUI { enum GUI {
START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP, START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP,
COMBAT_START COMBAT_START, NO_NEIGHBORS
}; };
struct Combat { struct Combat {

19
gui.cpp
View file

@ -99,9 +99,13 @@ namespace gui {
System::combat($level); System::combat($level);
run_systems(); run_systems();
$rotation = -10.0f; $rotation = -10.0f;
state(State::IDLE); state(State::IN_COMBAT);
} }
break; break;
case STOP_COMBAT:
dbc::log("Exiting ATTACKING STATE");
state(State::IDLE);
break;
default: default:
dbc::log(fmt::format("In ATTACKING state, unhandled event {}", (int)ev)); dbc::log(fmt::format("In ATTACKING state, unhandled event {}", (int)ev));
} }
@ -161,6 +165,7 @@ namespace gui {
case CLOSE: case CLOSE:
dbc::log("Nothing to close."); dbc::log("Nothing to close.");
break; break;
case STOP_COMBAT:
case TICK: case TICK:
// do nothing // do nothing
break; break;
@ -186,6 +191,9 @@ namespace gui {
$camera.plan_rotate($rayview, -1); $camera.plan_rotate($rayview, -1);
state(State::COMBAT_ROTATE); state(State::COMBAT_ROTATE);
break; break;
case STOP_COMBAT:
state(State::IDLE);
break;
case QUIT: case QUIT:
$window.close(); $window.close();
state(State::END); state(State::END);
@ -405,9 +413,12 @@ namespace gui {
} }
} }
break; break;
case eGUI::COMBAT_START: { case eGUI::COMBAT_START:
event(Event::START_COMBAT); event(Event::START_COMBAT);
} break; break;
case eGUI::NO_NEIGHBORS:
event(Event::STOP_COMBAT);
break;
case eGUI::LOOT: { case eGUI::LOOT: {
// auto &item = std::any_cast<InventoryItem&>(data); // auto &item = std::any_cast<InventoryItem&>(data);
// $status_view.log(fmt::format("You picked up a {}.", // $status_view.log(fmt::format("You picked up a {}.",

View file

@ -36,6 +36,7 @@ namespace gui {
ROTATE_RIGHT, ROTATE_RIGHT,
ATTACK, ATTACK,
START_COMBAT, START_COMBAT,
STOP_COMBAT,
QUIT QUIT
}; };

View file

@ -215,6 +215,8 @@ void System::collision(GameLevel &level) {
println("UNKNOWN COLLISION TYPE {}", entity); println("UNKNOWN COLLISION TYPE {}", entity);
} }
} }
} else {
world.send<Events::GUI>(Events::GUI::NO_NEIGHBORS, player.entity, player.entity);
} }
} }