diff --git a/assets/enemies.json b/assets/enemies.json index 34817f5..10f8c6b 100644 --- a/assets/enemies.json +++ b/assets/enemies.json @@ -6,7 +6,7 @@ "foreground": "enemies/fg:player", "background": "color:transparent" }, - {"_type": "Combat", "hp": 200, "max_hp": 200, "ap": 0, "max_ap": 12, "ap_delta": 6, "damage": 1000, "dead": false}, + {"_type": "Combat", "hp": 200, "max_hp": 200, "ap": 0, "max_ap": 12, "ap_delta": 6, "damage": 10, "dead": false}, {"_type": "Motion", "dx": 0, "dy": 0, "random": false}, {"_type": "Collision", "has": true}, {"_type": "EnemyConfig", "ai_script": "Host::actions", "ai_start_name": "Host::initial_state", "ai_goal_name": "Host::final_state"}, diff --git a/assets/shaders.json b/assets/shaders.json index 7a03ad7..4e13d67 100644 --- a/assets/shaders.json +++ b/assets/shaders.json @@ -18,5 +18,9 @@ "lightning": { "file_name": "assets/shaders/lightning_attack.frag", "type": "fragment" + }, + "boss_hit": { + "file_name": "assets/shaders/flame_trash.frag", + "type": "fragment" } } diff --git a/boss/fight.cpp b/boss/fight.cpp index 4a90888..b9f8fe8 100644 --- a/boss/fight.cpp +++ b/boss/fight.cpp @@ -66,7 +66,7 @@ namespace boss { break; case ATTACK: if($battle.player_request("kill_enemy")) { - fmt::println("player requests kill_enemy {} vs. {}", + fmt::println("player requests kill_enemy {} vs. {}", $host_combat->ap, $battle.player_pending_ap()); } else { fmt::println("NO MORE ACTION!"); diff --git a/boss/ui.cpp b/boss/ui.cpp index 9097542..403eef8 100644 --- a/boss/ui.cpp +++ b/boss/ui.cpp @@ -109,11 +109,12 @@ namespace boss { void UI::damage(const string& actor, const std::string& target, int amount) { if(amount > 0) { $arena.attach_text(target, fmt::format("{}", amount)); - $arena.apply_effect(actor, "flame"); + $arena.apply_effect(actor, "lightning"); // USING SCALE float scale = 0.8f; - $arena.zoom(target, scale); + std::string style = "pan"; + $arena.zoom(target, style, scale); } else { $arena.attach_text(actor, "MISSED"); } diff --git a/camera.cpp b/camera.cpp index 052e4f7..033635c 100644 --- a/camera.cpp +++ b/camera.cpp @@ -29,7 +29,7 @@ namespace cinematic { } Camera::Camera(sf::Vector2f size) : - anim(MGR.animations.at("dolly")), + anim(MGR.animations.at("pan")), size(size), base_size(size), aimed_at{size.x/2, size.y/2}, diff --git a/gui/combat_ui.cpp b/gui/combat_ui.cpp index f924713..c841cf2 100644 --- a/gui/combat_ui.cpp +++ b/gui/combat_ui.cpp @@ -24,6 +24,7 @@ namespace gui { { $gui.set(button, {icon_name}); $gui.set(button, {sound}); + $gui.set(button, {.duration=0.5f, .name=effect_name}); $gui.set(button, guecs::make_action(button, event, {action})); diff --git a/gui/event_router.cpp b/gui/event_router.cpp index 9a75428..b2afd32 100644 --- a/gui/event_router.cpp +++ b/gui/event_router.cpp @@ -136,7 +136,7 @@ namespace gui { set_event(game::Event::KEY_PRESS); break; default: - dbc::sentinel("invalid events"); + dbc::sentinel(fmt::format("invalid events: {}", int(ev))); } } } diff --git a/main.cpp b/main.cpp index 40664ba..00a6d95 100644 --- a/main.cpp +++ b/main.cpp @@ -12,13 +12,15 @@ int main(int argc, char* argv[]) { try { - components::init(); sfml::Backend backend; + + shaders::init(); + components::init(); guecs::init(&backend); ai::init("ai"); animation::init(); - cinematic::init(); GameDB::init(); + cinematic::init(); sound::mute(true); diff --git a/scene.cpp b/scene.cpp index f944aaa..759be2f 100644 --- a/scene.cpp +++ b/scene.cpp @@ -76,6 +76,7 @@ namespace scene { void Engine::apply_effect(const std::string& actor, const std::string& shader) { auto& element = actor_config(actor); element.effect = shaders::get(shader); + } void Engine::attach_text(const std::string& actor, const std::string& text) { @@ -100,8 +101,12 @@ namespace scene { } for(auto& actor : $actors) { - view.draw(*actor.st.sprite, actor.effect.get()); - if(actor.anim.playing) view.draw(actor.text); + if(actor.effect != nullptr) { + dbc::log(fmt::format("ACTOR {} SHADER {}", actor.name, (void*)actor.effect.get())); + } + + view.draw(*actor.st.sprite, actor.effect.get()); + if(actor.anim.playing) view.draw(actor.text); } $camera.render(view); @@ -139,7 +144,8 @@ namespace scene { actor.anim.apply(actor.text, actor.pos); if(actor.effect) { actor.effect->setUniform("u_time", actor.anim.subframe); - actor.effect->setUniform("u_duration", 1000); + sf::Vector2f u_resolution{float(actor.anim.frame_width), float(actor.anim.frame_height)}; + actor.effect->setUniform("u_resolution", u_resolution); } } else { actor.effect = nullptr; @@ -159,7 +165,8 @@ namespace scene { return pos; } - void Engine::zoom(float mid_x, float mid_y, float scale) { + void Engine::zoom(float mid_x, float mid_y, const std::string& style, float scale) { + $camera.style(style); $camera.scale(scale); $camera.move(mid_x, mid_y); $camera.play(); @@ -188,13 +195,13 @@ namespace scene { } } - void Engine::zoom(const std::string &actor, float scale) { + void Engine::zoom(const std::string &actor, const std::string& style, float scale) { auto& config = actor_config(actor); auto bounds = config.st.sprite->getGlobalBounds(); float mid_x = config.pos.x + bounds.size.x / 2.0f; float mid_y = config.pos.y + bounds.size.y / 2.0f; - zoom(mid_x, mid_y, scale); + zoom(mid_x, mid_y, style, scale); } void Engine::reset(sf::RenderTexture& view) { diff --git a/scene.hpp b/scene.hpp index 802539b..5ee8195 100644 --- a/scene.hpp +++ b/scene.hpp @@ -1,4 +1,5 @@ #pragma once + #include #include #include "components.hpp" @@ -51,8 +52,8 @@ namespace scene { void play_animations(); void apply_effect(const std::string& actor, const std::string& shader); Element& actor_config(const std::string& actor); - void zoom(const std::string& actor, float scale=0.9f); - void zoom(float mid_x, float mid_y, float scale); + void zoom(const std::string& actor, const std::string& style, float scale=0.9f); + void zoom(float mid_x, float mid_y, const std::string& style, float scale); void reset(sf::RenderTexture& view); std::pair left_right(const std::string &actor, const std::string &target); }; diff --git a/tools/arena.cpp b/tools/arena.cpp index 3c5c5fc..e13b804 100644 --- a/tools/arena.cpp +++ b/tools/arena.cpp @@ -16,6 +16,7 @@ void craft_weapon() { auto world = GameDB::current_world(); auto& the_belt = world->get_the(); + ritual::Action action{1.0, 20, ritual::Kind::MAGICK, ritual::Element::FIRE, {"fake"}}; the_belt.equip(the_belt.next(), action); }