|
|
@ -22,9 +22,10 @@ Matrix MAP{ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const int SCREEN_HEIGHT=480; |
|
|
|
const int SCREEN_HEIGHT=480; |
|
|
|
|
|
|
|
const int SCREEN_WIDTH=SCREEN_HEIGHT * 2; |
|
|
|
|
|
|
|
|
|
|
|
const int THREED_VIEW_WIDTH=480; |
|
|
|
const int THREED_VIEW_WIDTH=480; |
|
|
|
const int THREED_VIEW_HEIGHT=480; |
|
|
|
const int THREED_VIEW_HEIGHT=480; |
|
|
|
const int SCREEN_WIDTH=SCREEN_HEIGHT * 2; |
|
|
|
|
|
|
|
const int MAP_SIZE=matrix::width(MAP); |
|
|
|
const int MAP_SIZE=matrix::width(MAP); |
|
|
|
const int TILE_SIZE=(SCREEN_WIDTH/2) / MAP_SIZE; |
|
|
|
const int TILE_SIZE=(SCREEN_WIDTH/2) / MAP_SIZE; |
|
|
|
const float FOV = std::numbers::pi / 3.0; |
|
|
|
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; |
|
|
|
float wall_height = 21000 / fixed_depth; |
|
|
|
|
|
|
|
|
|
|
|
if(wall_height > SCREEN_HEIGHT){ |
|
|
|
if(wall_height > window.height()){ |
|
|
|
wall_height = SCREEN_HEIGHT; |
|
|
|
wall_height = window.height(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
draw_rect(window, |
|
|
|
draw_rect(window, |
|
|
|
{size_t(SCREEN_HEIGHT + ray * SCALE), |
|
|
|
{size_t(window.height() + ray * SCALE), |
|
|
|
size_t((SCREEN_HEIGHT / 2) - wall_height / 2)}, |
|
|
|
size_t((window.height() / 2) - wall_height / 2)}, |
|
|
|
{size_t(SCALE), size_t(wall_height)}, |
|
|
|
{size_t(SCALE), size_t(wall_height)}, |
|
|
|
gray_color(color)); |
|
|
|
gray_color(color)); |
|
|
|
} |
|
|
|
} |
|
|
@ -160,12 +161,12 @@ void ray_casting(Fenster &window, Matrix& map) { |
|
|
|
|
|
|
|
|
|
|
|
void draw_ceiling_floor(Fenster &window) { |
|
|
|
void draw_ceiling_floor(Fenster &window) { |
|
|
|
draw_rect(window, |
|
|
|
draw_rect(window, |
|
|
|
{size_t(SCREEN_HEIGHT), 0}, |
|
|
|
{size_t(window.width() / 2), 0}, |
|
|
|
{size_t(SCREEN_HEIGHT), size_t(SCREEN_HEIGHT / 2)}, |
|
|
|
{size_t(window.height()), size_t(window.height() / 2)}, |
|
|
|
gray_color(100)); |
|
|
|
gray_color(100)); |
|
|
|
draw_rect(window, |
|
|
|
draw_rect(window, |
|
|
|
{size_t(SCREEN_HEIGHT), size_t(SCREEN_HEIGHT / 2)}, |
|
|
|
{size_t(window.width() / 2), size_t(window.height() / 2)}, |
|
|
|
{size_t(SCREEN_HEIGHT), size_t(SCREEN_HEIGHT / 2)}, |
|
|
|
{size_t(window.width() / 2), size_t(window.height() / 2)}, |
|
|
|
gray_color(200)); |
|
|
|
gray_color(200)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|