Refactored the animation so I can normalize it to one api. Next is to create the concept of a temporary entity that represents a transitive effect.
This commit is contained in:
parent
0afaa20c1d
commit
8384b11993
10 changed files with 123 additions and 23 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "textures.hpp"
|
||||
#include "systems.hpp"
|
||||
#include "shaders.hpp"
|
||||
#include "animation.hpp"
|
||||
|
||||
using namespace fmt;
|
||||
using std::make_unique, std::shared_ptr;
|
||||
|
@ -104,6 +105,7 @@ void Raycaster::apply_sprite_effect(shared_ptr<sf::Shader> effect, float width,
|
|||
|
||||
void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
||||
auto& lights = $level.lights->lighting();
|
||||
auto world = $level.world;
|
||||
$level.collision->distance_sorted($sprite_order, {(size_t)$pos_x, (size_t)$pos_y}, RENDER_DISTANCE);
|
||||
|
||||
|
||||
|
@ -118,7 +120,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
int half_height = texture_height / 2;
|
||||
|
||||
auto& sf_sprite = sprite_texture.sprite;
|
||||
auto sprite_pos = $level.world->get<components::Position>(rec.entity);
|
||||
auto sprite_pos = world->get<components::Position>(rec.entity);
|
||||
|
||||
double sprite_x = double(sprite_pos.location.x) - rec.wiggle - $pos_x + 0.5;
|
||||
double sprite_y = double(sprite_pos.location.y) - rec.wiggle - $pos_y + 0.5;
|
||||
|
@ -187,10 +189,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
sf::Vector2f position{x + origin.x * scale.x, y + origin.y * scale.y};
|
||||
sf::IntRect in_texture{ {tex_x, tex_y}, {tex_render_width, texture_height}};
|
||||
|
||||
if($level.world->has<components::Animation>(rec.entity)) {
|
||||
auto& animation = $level.world->get<components::Animation>(rec.entity);
|
||||
if(animation.playing) animation.step(scale, position, in_texture);
|
||||
}
|
||||
animation::step_animation(*world, rec.entity, scale, position, in_texture);
|
||||
|
||||
sf_sprite->setOrigin(origin);
|
||||
sf_sprite->setScale(scale);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue