diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_sprite.c | 20 | ||||
-rw-r--r-- | src/ft_raycasting.c | 12 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c index 43de290..806489f 100644 --- a/src/ft_get_sprite.c +++ b/src/ft_get_sprite.c @@ -17,8 +17,26 @@ void ft_get_sprite_spawn(t_cub *clist) { + size_t x; + size_t y; - (void)clist; + x = 1; + y = 1; + while (clist->mlist->map[y]) + { + while (clist->mlist->map[y][x]) + { + if (ft_ischarset("2", clist->mlist->map[y][x])) + { + clist->sp_list.s_pos_x = x + 0.5; + clist->sp_list.s_pos_y = y + 0.5; + return ; + } + x++; + } + x = 1; + y++; + } } int8_t diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index dd2be64..589d2da 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -16,6 +16,17 @@ #include <math.h> void + ft_calc_sprite(t_cub *cl) +{ + cl->sp_list.s_x = cl->sp_list.s_pos_x - cl->plist->pos_x; + cl->sp_list.s_y = cl->sp_list.s_pos_y - cl->plist->pos_y; + cl->sp_list.inv_c_m = 1.0 / (cl->plist->plane_x * cl->plist->dir_x - cl->plist->dir_y * cl->plist->plane_y); + cl->sp_list.sprite_transform_x = cl->sp_list.inv_c_m * (cl->plist->dir_y * cl->sp_list.s_x - cl->plist->dir_x * cl->sp_list.s_y); + cl->sp_list.sprite_transform_y = cl->sp_list.inv_c_m * (cl->plist->plane_y * cl->sp_list.s_x - cl->plist->plane_x * cl->sp_list.s_y); + +} + +static void ft_calc_tex(t_cub *clist) { if (clist->rlist.side == 0) @@ -83,6 +94,7 @@ void cl->rlist.wall_b = wl->y_size - 1; ft_choose_tex(cl); ft_calc_tex(cl); + ft_calc_sprite(cl); ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); i++; } |