diff --git a/fenscaster.cpp b/fenscaster.cpp index 4ba5df0..218ddfa 100644 --- a/fenscaster.cpp +++ b/fenscaster.cpp @@ -22,9 +22,10 @@ Matrix MAP{ }; const int SCREEN_HEIGHT=480; +const int SCREEN_WIDTH=SCREEN_HEIGHT * 2; + const int THREED_VIEW_WIDTH=480; const int THREED_VIEW_HEIGHT=480; -const int SCREEN_WIDTH=SCREEN_HEIGHT * 2; const int MAP_SIZE=matrix::width(MAP); const int TILE_SIZE=(SCREEN_WIDTH/2) / MAP_SIZE; const float FOV = std::numbers::pi / 3.0; @@ -125,13 +126,13 @@ void draw_3d_view(Fenster &window, int depth, float start_angle, int ray) { float wall_height = 21000 / fixed_depth; - if(wall_height > SCREEN_HEIGHT){ - wall_height = SCREEN_HEIGHT; + if(wall_height > window.height()){ + wall_height = window.height(); } draw_rect(window, - {size_t(SCREEN_HEIGHT + ray * SCALE), - size_t((SCREEN_HEIGHT / 2) - wall_height / 2)}, + {size_t(window.height() + ray * SCALE), + size_t((window.height() / 2) - wall_height / 2)}, {size_t(SCALE), size_t(wall_height)}, gray_color(color)); } @@ -160,12 +161,12 @@ void ray_casting(Fenster &window, Matrix& map) { void draw_ceiling_floor(Fenster &window) { draw_rect(window, - {size_t(SCREEN_HEIGHT), 0}, - {size_t(SCREEN_HEIGHT), size_t(SCREEN_HEIGHT / 2)}, + {size_t(window.width() / 2), 0}, + {size_t(window.height()), size_t(window.height() / 2)}, gray_color(100)); draw_rect(window, - {size_t(SCREEN_HEIGHT), size_t(SCREEN_HEIGHT / 2)}, - {size_t(SCREEN_HEIGHT), size_t(SCREEN_HEIGHT / 2)}, + {size_t(window.width() / 2), size_t(window.height() / 2)}, + {size_t(window.width() / 2), size_t(window.height() / 2)}, gray_color(200)); } diff --git a/fenster/fenster.h b/fenster/fenster.h index 2da5d4a..9e35a03 100644 --- a/fenster/fenster.h +++ b/fenster/fenster.h @@ -364,6 +364,8 @@ public: int y() { return this->f.y; } int mouse() { return this->f.mouse; } int mod() { return this->f.mod; } + int width() { return this->f.width; } + int height() { return this->f.height; } }; #endif /* __cplusplus */