Basic simple animations where the enemies just move forward.

This commit is contained in:
Zed A. Shaw 2025-02-22 01:36:31 -05:00
parent 947ccbe180
commit 80a0f2ba75
9 changed files with 92 additions and 80 deletions

View file

@ -80,6 +80,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
// after sorting the sprites, do the projection
for(auto& rec : sprite_order) {
if(!$sprites.contains(rec.second)) continue;
// BUG: eventually this needs to go away too
auto& sf_sprite = $sprites.at(rec.second).sprite;
auto sprite_pos = $level.world->get<components::Position>(rec.second);
@ -145,12 +146,17 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
int d = y * texture_height - $height * half_height + sprite_height * half_height;
int tex_y = ((d * texture_height) / sprite_height) / texture_height;
sf_sprite->setScale({sprite_scale_w, sprite_scale_h});
sf_sprite->setTextureRect(sf::IntRect({
{tex_x, tex_y},
{tex_render_width, texture_height}}));
sf_sprite->setPosition({x, y});
sf::Vector2f scale{sprite_scale_w, sprite_scale_h};
sf::IntRect in_texture{ {tex_x, tex_y}, {tex_render_width, texture_height}};
if($level.world->has<components::Animation>(rec.second)) {
auto& animation = $level.world->get<components::Animation>(rec.second);
animation.step(scale, in_texture);
}
sf_sprite->setScale(scale);
sf_sprite->setTextureRect(in_texture);
sf_sprite->setPosition({x, y});
$brightness.setUniform("offsetFactor", sf::Glsl::Vec2{0.0f, 0.0f});
// the SpatialMap.distance_sorted only calculates the