The shader effects now work correctly on the scene actors, but the application of shaders should be on the animation class.
This commit is contained in:
parent
22db12f5e4
commit
05fc9062a7
11 changed files with 33 additions and 16 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
"foreground": "enemies/fg:player",
|
"foreground": "enemies/fg:player",
|
||||||
"background": "color:transparent"
|
"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": "Motion", "dx": 0, "dy": 0, "random": false},
|
||||||
{"_type": "Collision", "has": true},
|
{"_type": "Collision", "has": true},
|
||||||
{"_type": "EnemyConfig", "ai_script": "Host::actions", "ai_start_name": "Host::initial_state", "ai_goal_name": "Host::final_state"},
|
{"_type": "EnemyConfig", "ai_script": "Host::actions", "ai_start_name": "Host::initial_state", "ai_goal_name": "Host::final_state"},
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,9 @@
|
||||||
"lightning": {
|
"lightning": {
|
||||||
"file_name": "assets/shaders/lightning_attack.frag",
|
"file_name": "assets/shaders/lightning_attack.frag",
|
||||||
"type": "fragment"
|
"type": "fragment"
|
||||||
|
},
|
||||||
|
"boss_hit": {
|
||||||
|
"file_name": "assets/shaders/flame_trash.frag",
|
||||||
|
"type": "fragment"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,11 +109,12 @@ namespace boss {
|
||||||
void UI::damage(const string& actor, const std::string& target, int amount) {
|
void UI::damage(const string& actor, const std::string& target, int amount) {
|
||||||
if(amount > 0) {
|
if(amount > 0) {
|
||||||
$arena.attach_text(target, fmt::format("{}", amount));
|
$arena.attach_text(target, fmt::format("{}", amount));
|
||||||
$arena.apply_effect(actor, "flame");
|
$arena.apply_effect(actor, "lightning");
|
||||||
|
|
||||||
// USING SCALE
|
// USING SCALE
|
||||||
float scale = 0.8f;
|
float scale = 0.8f;
|
||||||
$arena.zoom(target, scale);
|
std::string style = "pan";
|
||||||
|
$arena.zoom(target, style, scale);
|
||||||
} else {
|
} else {
|
||||||
$arena.attach_text(actor, "MISSED");
|
$arena.attach_text(actor, "MISSED");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace cinematic {
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera::Camera(sf::Vector2f size) :
|
Camera::Camera(sf::Vector2f size) :
|
||||||
anim(MGR.animations.at("dolly")),
|
anim(MGR.animations.at("pan")),
|
||||||
size(size),
|
size(size),
|
||||||
base_size(size),
|
base_size(size),
|
||||||
aimed_at{size.x/2, size.y/2},
|
aimed_at{size.x/2, size.y/2},
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ namespace gui {
|
||||||
{
|
{
|
||||||
$gui.set<Sprite>(button, {icon_name});
|
$gui.set<Sprite>(button, {icon_name});
|
||||||
$gui.set<Sound>(button, {sound});
|
$gui.set<Sound>(button, {sound});
|
||||||
|
|
||||||
$gui.set<Effect>(button, {.duration=0.5f, .name=effect_name});
|
$gui.set<Effect>(button, {.duration=0.5f, .name=effect_name});
|
||||||
$gui.set<Clickable>(button,
|
$gui.set<Clickable>(button,
|
||||||
guecs::make_action(button, event, {action}));
|
guecs::make_action(button, event, {action}));
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ namespace gui {
|
||||||
set_event(game::Event::KEY_PRESS);
|
set_event(game::Event::KEY_PRESS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dbc::sentinel("invalid events");
|
dbc::sentinel(fmt::format("invalid events: {}", int(ev)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
main.cpp
6
main.cpp
|
|
@ -12,13 +12,15 @@
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
try {
|
try {
|
||||||
components::init();
|
|
||||||
sfml::Backend backend;
|
sfml::Backend backend;
|
||||||
|
|
||||||
|
shaders::init();
|
||||||
|
components::init();
|
||||||
guecs::init(&backend);
|
guecs::init(&backend);
|
||||||
ai::init("ai");
|
ai::init("ai");
|
||||||
animation::init();
|
animation::init();
|
||||||
cinematic::init();
|
|
||||||
GameDB::init();
|
GameDB::init();
|
||||||
|
cinematic::init();
|
||||||
|
|
||||||
sound::mute(true);
|
sound::mute(true);
|
||||||
|
|
||||||
|
|
|
||||||
15
scene.cpp
15
scene.cpp
|
|
@ -76,6 +76,7 @@ namespace scene {
|
||||||
void Engine::apply_effect(const std::string& actor, const std::string& shader) {
|
void Engine::apply_effect(const std::string& actor, const std::string& shader) {
|
||||||
auto& element = actor_config(actor);
|
auto& element = actor_config(actor);
|
||||||
element.effect = shaders::get(shader);
|
element.effect = shaders::get(shader);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::attach_text(const std::string& actor, const std::string& text) {
|
void Engine::attach_text(const std::string& actor, const std::string& text) {
|
||||||
|
|
@ -100,6 +101,10 @@ namespace scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& actor : $actors) {
|
for(auto& actor : $actors) {
|
||||||
|
if(actor.effect != nullptr) {
|
||||||
|
dbc::log(fmt::format("ACTOR {} SHADER {}", actor.name, (void*)actor.effect.get()));
|
||||||
|
}
|
||||||
|
|
||||||
view.draw(*actor.st.sprite, actor.effect.get());
|
view.draw(*actor.st.sprite, actor.effect.get());
|
||||||
if(actor.anim.playing) view.draw(actor.text);
|
if(actor.anim.playing) view.draw(actor.text);
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +144,8 @@ namespace scene {
|
||||||
actor.anim.apply(actor.text, actor.pos);
|
actor.anim.apply(actor.text, actor.pos);
|
||||||
if(actor.effect) {
|
if(actor.effect) {
|
||||||
actor.effect->setUniform("u_time", actor.anim.subframe);
|
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 {
|
} else {
|
||||||
actor.effect = nullptr;
|
actor.effect = nullptr;
|
||||||
|
|
@ -159,7 +165,8 @@ namespace scene {
|
||||||
return pos;
|
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.scale(scale);
|
||||||
$camera.move(mid_x, mid_y);
|
$camera.move(mid_x, mid_y);
|
||||||
$camera.play();
|
$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& config = actor_config(actor);
|
||||||
auto bounds = config.st.sprite->getGlobalBounds();
|
auto bounds = config.st.sprite->getGlobalBounds();
|
||||||
float mid_x = config.pos.x + bounds.size.x / 2.0f;
|
float mid_x = config.pos.x + bounds.size.x / 2.0f;
|
||||||
float mid_y = config.pos.y + bounds.size.y / 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) {
|
void Engine::reset(sf::RenderTexture& view) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "components.hpp"
|
#include "components.hpp"
|
||||||
|
|
@ -51,8 +52,8 @@ namespace scene {
|
||||||
void play_animations();
|
void play_animations();
|
||||||
void apply_effect(const std::string& actor, const std::string& shader);
|
void apply_effect(const std::string& actor, const std::string& shader);
|
||||||
Element& actor_config(const std::string& actor);
|
Element& actor_config(const std::string& actor);
|
||||||
void zoom(const std::string& actor, float scale=0.9f);
|
void zoom(const std::string& actor, const std::string& style, float scale=0.9f);
|
||||||
void zoom(float mid_x, float mid_y, float scale);
|
void zoom(float mid_x, float mid_y, const std::string& style, float scale);
|
||||||
void reset(sf::RenderTexture& view);
|
void reset(sf::RenderTexture& view);
|
||||||
std::pair<Element&, Element&> left_right(const std::string &actor, const std::string &target);
|
std::pair<Element&, Element&> left_right(const std::string &actor, const std::string &target);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
void craft_weapon() {
|
void craft_weapon() {
|
||||||
auto world = GameDB::current_world();
|
auto world = GameDB::current_world();
|
||||||
auto& the_belt = world->get_the<ritual::Belt>();
|
auto& the_belt = world->get_the<ritual::Belt>();
|
||||||
|
|
||||||
ritual::Action action{1.0, 20, ritual::Kind::MAGICK, ritual::Element::FIRE, {"fake"}};
|
ritual::Action action{1.0, 20, ritual::Kind::MAGICK, ritual::Element::FIRE, {"fake"}};
|
||||||
the_belt.equip(the_belt.next(), action);
|
the_belt.equip(the_belt.next(), action);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue