Sprite is no more, now using the position from the level's world.

This commit is contained in:
Zed A. Shaw 2025-02-05 11:46:40 -05:00
parent d0badedbd9
commit d5301acab5
3 changed files with 9 additions and 14 deletions

View file

@ -7,6 +7,7 @@
#include <fmt/core.h>
#include <memory>
#include <numbers>
#include "components.hpp"
using namespace fmt;
using std::make_unique;
@ -69,12 +70,12 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
// after sorting the sprites, do the projection
for(auto& rec : sprite_order) {
const Sprite& sprite_rec = $sprites.at(rec.second);
// TODO: this must die
auto sf_sprite = sprite_rec.sprite.sprite;
// 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);
double spriteX = sprite_rec.x - $posX;
double spriteY = sprite_rec.y - $posY;
double spriteX = double(sprite_pos.location.x) - $posX + 0.5;
double spriteY = double(sprite_pos.location.y) - $posY + 0.5;
//transform sprite with the inverse camera matrix
// [ $planeX $dirX ] -1 [ $dirY -$dirX ]
@ -335,6 +336,6 @@ void Raycaster::set_level(GameLevel level) {
// this will need to go away too but for now everything is evil eye
for(auto &thing : $level.collision->table) {
auto sprite_txt = $textures.sprite_textures.at("evil_eye");
$sprites.try_emplace(thing.second, thing.first.x + 0.5, thing.first.y + 0.5, sprite_txt);
$sprites.try_emplace(thing.second, sprite_txt);
}
}