Fixed that crash and cleaned up more variables for some study next. I might also try out my debug macros.

This commit is contained in:
Zed A. Shaw 2025-01-18 00:44:25 -05:00
parent 7fb2d5cf26
commit 7a74877849
9 changed files with 162 additions and 92729 deletions

View file

@ -16,24 +16,23 @@ using matrix::Matrix;
using RGBA = uint32_t;
struct Raycaster {
int PITCH=0;
int $pitch=0;
TexturePack textures;
double posX = 0;
double posY = 0;
TexturePack $textures;
double $posX = 0;
double $posY = 0;
// initial direction vector
double dirX = -1;
double dirY = 0;
double $dirX = -1;
double $dirY = 0;
// the 2d raycaster version of camera plane
double planeX = 0;
double planeY = 0.66;
sf::Texture view_texture;
sf::Sprite view_sprite;
double $planeX = 0;
double $planeY = 0.66;
sf::Texture $view_texture;
sf::Sprite $view_sprite;
//ZED: USE smart pointer for this
std::unique_ptr<RGBA[]> pixels = nullptr;
std::unique_ptr<RGBA[]> $pixels = nullptr;
int $width;
int $height;
@ -61,6 +60,14 @@ struct Raycaster {
void set_position(int x, int y);
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);
}