Removed some of the constants to make it easier to change later.

master
Zed A. Shaw 16 hours ago
parent 35f6fcc01d
commit 75a927e192
  1. 19
      fenscaster.cpp
  2. 2
      fenster/fenster.h

@ -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));
}

@ -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 */

Loading…
Cancel
Save