diff options
-rw-r--r-- | inc/cub3d.h | 15 | ||||
-rw-r--r-- | map/map_one.cub | 2 | ||||
-rw-r--r-- | src/ft_drawmap.c | 31 |
3 files changed, 47 insertions, 1 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h index 7b6cfc5..0d1c8df 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -78,6 +78,21 @@ typedef struct s_player float view_side; } t_player; +typedef struct s_ray +{ + double x_ray_position; + double y_ray_position; + double x_ray_direction; + double y_ray_direction; + double x_side_distance; + double y_side_distance; + double x_delta_distance; + double y_delta_distance; + int hitX; + int hitY; + int hits[150]; +} t_ray; + typedef struct s_cub { char *no_tex_path; diff --git a/map/map_one.cub b/map/map_one.cub index 2a4c17a..9bb7687 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -1,4 +1,4 @@ -R 1200 600 +R 20800 11600 NO ./path_to_the_north_texture SO ./path_to_the_south_texture diff --git a/src/ft_drawmap.c b/src/ft_drawmap.c index 7d7cafe..97ed6b0 100644 --- a/src/ft_drawmap.c +++ b/src/ft_drawmap.c @@ -46,6 +46,36 @@ static void } } +void ft_drawline(t_cub *clist, int startX, int startY) +{ + int a; + int b; + int p; + int x; + int y; + + x = startX; + y = startY; + while (x > 25 * clist->scale) + { + a = 2 * (y - 1 * clist->scale); + b = a - (2 * (x - 25 * clist->scale)); + p = a - (x - 25 * clist->scale); + if (p < 0) + { + x--; + *(int*)(clist->img.ptr + (x * 4 + (y * clist->img.sizeline))) = 0x00ff0000; + p += a; + } + else if (p >= 0) + { + y--; + *(int*)(clist->img.ptr + (x * 4 + (y * clist->img.sizeline))) = 0x00ff0000; + p += b; + } + x--; + } +} static void ft_draw_player(t_player *plist, t_cub *clist) { @@ -56,6 +86,7 @@ static void ft_drawsquare(scale + (x * (scale + 1)), scale + (y * (scale + 1)), 0x009843fa, clist); + ft_drawline(clist, x * (scale + 1), y * (scale + 1)); } void |