aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_raycasting.c
diff options
context:
space:
mode:
authorsalaaad2 <arthudurant263@gmail.com>2020-02-25 16:43:54 +0100
committersalaaad2 <arthudurant263@gmail.com>2020-02-25 16:43:54 +0100
commitcc85b0a701b558e18299822f7091fc2fd137b14b (patch)
treed2d914c1242299e8c3d2afcec8ff6b3c12d2a82f /src/ft_raycasting.c
parentgang (diff)
download42-cub3d-cc85b0a701b558e18299822f7091fc2fd137b14b.tar.gz
42-cub3d-cc85b0a701b558e18299822f7091fc2fd137b14b.tar.bz2
42-cub3d-cc85b0a701b558e18299822f7091fc2fd137b14b.tar.xz
42-cub3d-cc85b0a701b558e18299822f7091fc2fd137b14b.tar.zst
42-cub3d-cc85b0a701b558e18299822f7091fc2fd137b14b.zip
bunch of garbage
Diffstat (limited to '')
-rw-r--r--src/ft_raycasting.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 5bf0785..be4a815 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -20,44 +20,45 @@
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_y
+ cl->sprites.s_x = cl->sprites.s_pos_x - cl->plist->pos_x;
+ cl->sprites.s_y = cl->sprites.s_pos_y - cl->plist->pos_y;
+ cl->sprites.inv_c_m = 1.0 / (cl->plist->plane_x * cl->plist->dir_y
- cl->plist->dir_x * 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);
- cl->sp_list.s_screen_x = (int)((cl->wlist->y_size / 2)
- * (1 + cl->sp_list.sprite_transform_x
- / cl->sp_list.sprite_transform_y));
- cl->sp_list.s_h =
- abs((int)(cl->wlist->y_size * cl->sp_list.sprite_transform_y));
+ cl->sprites.sprite_transform_x = cl->sprites.inv_c_m
+ * (cl->plist->dir_y * cl->sprites.s_x
+ - cl->plist->dir_x * cl->sprites.s_y);
+ cl->sprites.sprite_transform_y = cl->sprites.inv_c_m
+ * (-cl->plist->plane_y * cl->sprites.s_x
+ + cl->plist->plane_x * cl->sprites.s_y);
+ cl->sprites.s_screen_x = (int)((cl->wlist->x_size / 2)
+ * (1 + cl->sprites.sprite_transform_x
+ / cl->sprites.sprite_transform_y));
+ cl->sprites.s_h =
+ abs((int)(cl->wlist->y_size * cl->sprites.sprite_transform_y));
ft_calc_sprite_norme(cl);
}
void
ft_calc_sprite_norme(t_cub *cl)
{
- cl->sp_list.s_start_y = -cl->sp_list.s_h / 2 + cl->wlist->y_size / 2;
- if (cl->sp_list.s_start_y < 0)
- cl->sp_list.s_start_y = 0;
- cl->sp_list.s_end_y = cl->sp_list.s_h / 2 + cl->wlist->y_size / 2;
- if (cl->sp_list.s_end_y > (int)cl->wlist->y_size)
- cl->sp_list.s_end_y = cl->wlist->y_size - 1;
- cl->sp_list.s_w = abs((int)(cl->wlist->x_size
- * cl->sp_list.sprite_transform_y)); /*sprite width*/
- cl->sp_list.s_start_x = -cl->sp_list.s_w / 2 + cl->sp_list.s_screen_x;
- if (cl->sp_list.s_start_x < 0)
- cl->sp_list.s_start_y = 0;
- cl->sp_list.s_end_x = cl->sp_list.s_w / 2 + cl->wlist->x_size;
- if (cl->sp_list.s_end_x < (int)cl->wlist->x_size)
- cl->sp_list.s_end_x = cl->wlist->x_size - 1;
- /*ft_printf("start x: %d\nstart y : %d\n", cl->sp_list.s_start_x, cl->sp_list.s_start_y);*/
- /*ft_printf("end x: %d\nend y : %d\n", cl->sp_list.s_end_x, cl->sp_list.s_end_y);*/
- ft_draw_sprite(cl);
+ cl->sprites.s_start_y = -cl->sprites.s_h / 2 + cl->wlist->y_size / 2;
+ if (cl->sprites.s_start_y < 0)
+ cl->sprites.s_start_y = 0;
+ cl->sprites.s_end_y = cl->sprites.s_h / 2 + cl->wlist->y_size / 2;
+ if (cl->sprites.s_end_y > (int)cl->wlist->y_size)
+ cl->sprites.s_end_y = cl->wlist->y_size - 1;
+ cl->sprites.s_w = abs((int)(cl->wlist->y_size
+ / cl->sprites.sprite_transform_y)); /*sprite width*/
+ cl->sprites.s_start_x = -cl->sprites.s_w / 2 + cl->sprites.s_screen_x;
+ if (cl->sprites.s_start_x < 0)
+ cl->sprites.s_start_x = 0;
+ cl->sprites.s_end_x = cl->sprites.s_w / 2 + cl->sprites.s_screen_x;
+ printf("%d\n", cl->sprites.s_w);
+ if (cl->sprites.s_end_x > (int)cl->wlist->x_size)
+ cl->sprites.s_end_x = cl->wlist->x_size - 1;
+ /*ft_printf("start x: %d\nend x : %d\n", cl->sprites.s_start_x, cl->sprites.s_end_x);*/
+ /*ft_printf("start y: %d\nend y : %d\n", cl->sprites.s_start_y, cl->sprites.s_end_y);*/
+ /*ft_draw_sprite(cl);*/
}