More cleanup of the raycaster, finally removed the window as a dependency but I went against making it an sf::Drawable since that had a lot of code quality problems.

This commit is contained in:
Zed A. Shaw 2025-02-04 22:52:04 -05:00
parent d6c09e111d
commit d0badedbd9
5 changed files with 25 additions and 74 deletions

View file

@ -32,42 +32,26 @@ struct Raycaster {
int $width;
int $height;
sf::RenderWindow& $window;
GameLevel $level;
Matrix $map;
SpatialMap $collision;
std::vector<Sprite> $sprites;
std::unordered_map<DinkyECS::Entity, Sprite> $sprites;
std::vector<double> ZBuffer; // width
Animator $anim;
sf::Shader $paused;
sf::Shader* $active_shader = nullptr;
Raycaster(sf::RenderWindow& window, TexturePack &textures, int width, int height);
Raycaster(TexturePack &textures, int width, int height);
void draw_pixel_buffer();
void clear();
void cast_rays();
void draw_ceiling_floor();
void sprite_casting();
void draw_pixel_buffer();
void sprite_casting(sf::RenderTarget& target);
void draw(sf::RenderTarget& target);
void sort_sprites(std::vector<int>& order, std::vector<double>& dist, int amount);
void render();
bool empty_space(int new_x, int new_y);
void position_camera(float player_x, float player_y);
void set_position(int x, int y);
void init_shaders();
DinkyECS::Entity position_sprite(Point pos, string name);
inline size_t pixcoord(int x, int y) {
if(!(x >=0 && x < $width)) {
dbc::sentinel(fmt::format("pixcoord x={} but $width={}", x, $width));
}
if(!(y >= 0 && y < $height)) {
dbc::sentinel(fmt::format("pixcoord y={} but $height={}", y, $height));
}
return ((y) * $width) + (x);
}