diff --git a/framebuffer.cpp b/framebuffer.cpp index d5715e4..dab65db 100644 --- a/framebuffer.cpp +++ b/framebuffer.cpp @@ -1,6 +1,3 @@ -#include -#include -#include #include #include "framebuffer.h" diff --git a/framebuffer.h b/framebuffer.h index 6acf5fc..067dafa 100644 --- a/framebuffer.h +++ b/framebuffer.h @@ -1,7 +1,7 @@ #ifndef FRAMEBUFFER_H #define FRAMEBUFFER_H -#include +#include #include struct FrameBuffer { diff --git a/gui.cpp b/gui.cpp index a4c8dc5..a44fdda 100644 --- a/gui.cpp +++ b/gui.cpp @@ -3,12 +3,7 @@ #include #include "SDL.h" -#include "map.h" #include "utils.h" -#include "player.h" -#include "sprite.h" -#include "framebuffer.h" -#include "textures.h" #include "tinyraycaster.h" int main() { diff --git a/map.cpp b/map.cpp index 6a762c0..53cfb04 100644 --- a/map.cpp +++ b/map.cpp @@ -1,6 +1,4 @@ -#include #include - #include "map.h" static const char map[] = "0000222222220000"\ diff --git a/sprite.cpp b/sprite.cpp index 8fcf313..217be74 100644 --- a/sprite.cpp +++ b/sprite.cpp @@ -1,4 +1,3 @@ -#include #include "sprite.h" bool Sprite::operator < (const Sprite& s) const { diff --git a/textures.cpp b/textures.cpp index 6f86ddd..3c5d857 100644 --- a/textures.cpp +++ b/textures.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" diff --git a/textures.h b/textures.h index 0bafcda..e4b12a4 100644 --- a/textures.h +++ b/textures.h @@ -1,6 +1,9 @@ #ifndef TEXTURES_H #define TEXTURES_H +#include +#include + struct Texture { size_t img_w, img_h; // overall image dimensions size_t count, size; // number of textures and size in pixels diff --git a/tinyraycaster.cpp b/tinyraycaster.cpp index 7522ffd..f143ede 100644 --- a/tinyraycaster.cpp +++ b/tinyraycaster.cpp @@ -1,18 +1,9 @@ #define _USE_MATH_DEFINES #include #include -#include -#include #include -#include -#include -#include "map.h" #include "utils.h" -#include "player.h" -#include "sprite.h" -#include "framebuffer.h" -#include "textures.h" #include "tinyraycaster.h" int wall_x_texcoord(const float hitx, const float hity, const Texture &tex_walls) { @@ -49,8 +40,8 @@ void draw_sprite(FrameBuffer &fb, const Sprite &sprite, const std::vector while (sprite_dir - player.a > M_PI) sprite_dir -= 2*M_PI; // remove unncesessary periods from the relative direction while (sprite_dir - player.a < -M_PI) sprite_dir += 2*M_PI; - size_t sprite_screen_size = std::min(1000, static_cast(fb.h/sprite.player_dist)); // screen sprite size - int h_offset = (sprite_dir - player.a)*(fb.w/2) + (fb.w/2)/2 - tex_sprites.size/2; // do not forget the 3D view takes only a half of the framebuffer + size_t sprite_screen_size = std::min(2000, static_cast(fb.h/sprite.player_dist)); // screen sprite size + int h_offset = (sprite_dir - player.a)*(fb.w/2)/(player.fov) + (fb.w/2)/2 - sprite_screen_size/2; // do not forget the 3D view takes only a half of the framebuffer, thus fb.w/2 for the screen width int v_offset = fb.h/2 - sprite_screen_size/2; for (size_t i=0; i + +#include "map.h" +#include "player.h" +#include "sprite.h" +#include "framebuffer.h" +#include "textures.h" + struct GameState { Map map; Player player; diff --git a/utils.cpp b/utils.cpp index 2d49fb9..c2f5e9e 100644 --- a/utils.cpp +++ b/utils.cpp @@ -1,7 +1,4 @@ -#include #include -#include -#include #include #include "utils.h"