Basic arena working that lets me work on the boss fight system quicker.

This commit is contained in:
Zed A. Shaw 2025-10-16 12:00:33 -04:00
parent 7f10c5b3d7
commit a578c49a77
11 changed files with 110 additions and 217 deletions

View file

@ -1,45 +1,77 @@
#include "arena_fsm.hpp"
#include "gui/fsm.hpp"
#include "textures.hpp"
#include "sound.hpp"
#include "autowalker.hpp"
#include "ai.hpp"
#include "animation.hpp"
#include <iostream>
#include "shaders.hpp"
#include "backend.hpp"
#include "game_level.hpp"
#include "boss/system.hpp"
#include "gui/fsm_events.hpp"
#include "events.hpp"
#include "constants.hpp"
#include "gui/event_router.hpp"
int main(int argc, char* argv[]) {
try {
dbc::check(argc == 2, "USAGE: arena enemy_name");
std::string enemy_name{argv[1]};
void craft_weapon() {
auto world = GameDB::current_world();
auto& the_belt = world->get_the<ritual::Belt>();
ritual::Action action{1.0, 20, ritual::Kind::MAGICK, ritual::Element::FIRE, {"fake"}};
the_belt.equip(the_belt.next(), action);
}
textures::init();
sound::init();
ai::init("ai");
animation::init();
int main(int, char*[]) {
components::init();
sfml::Backend backend;
guecs::init(&backend);
ai::init("ai");
animation::init();
GameDB::init();
sound::mute(false);
sound::play("ambient_1", true);
sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Bossfight Testing Arena");
gui::routing::Router router;
arena::FSM main(enemy_name);
sound::mute(true);
sound::play("ambient_1", true);
main.event(arena::Event::STARTED);
GameDB::create_level();
craft_weapon();
while(main.active()) {
main.render();
auto main = boss::System::create_bossfight();
auto world = GameDB::current_world();
// ZED: need to sort out how to deal with this in the FSM
if(main.in_state(arena::State::IDLE)) {
main.event(arena::Event::TICK);
while(!main->in_state(boss::State::END)) {
main->mouse_pos = window.mapPixelToCoords(router.position);
while(const auto ev = window.pollEvent()) {
auto gui_ev = router.process_event(ev);
if(gui_ev == gui::Event::QUIT || main->event(gui_ev, {})) {
return 0;
} else {
main->event(gui::Event::TICK, {});
}
main.keyboard_mouse();
main.handle_world_events();
}
return 0;
} catch(const std::system_error& e) {
std::cout << "WARNING: On OSX you'll get this error on shutdown.\n";
std::cout << "Caught system_error with code "
"[" << e.code() << "] meaning "
"[" << e.what() << "]\n";
while(world->has_event<Events::GUI>()) {
auto [evt, entity, data] = world->recv<Events::GUI>();
// FIX YOUR DAMN EVENTS
switch(evt) {
case Events::GUI::ATTACK:
main->event(gui::Event::ATTACK, data);
break;
default:
fmt::println("GUI EVENT: {} entity={}", int(evt), entity);
}
}
window.clear();
main->render(window);
window.display();
}
return 0;
}