diff options
Diffstat (limited to '')
-rw-r--r-- | map/map_one.cub | 4 | ||||
-rw-r--r-- | src/ft_get_sprite.c | 4 | ||||
-rw-r--r-- | src/ft_raycasting.c | 16 |
3 files changed, 16 insertions, 8 deletions
diff --git a/map/map_one.cub b/map/map_one.cub index a2d9329..644a63d 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -10,9 +10,9 @@ C 50,100,200 F 50,190,124 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 2 2 2 2 0 0 0 0 0 1 1 0 0 0 0 0 1 +1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 N 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 +1 N 1 1 0 0 0 2 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c index d99f12e..5f9a0bc 100644 --- a/src/ft_get_sprite.c +++ b/src/ft_get_sprite.c @@ -28,8 +28,8 @@ void { if (ft_ischarset("2", clist->mlist->map[y][x])) { - clist->sprites.spritex = x + 0.5; - clist->sprites.spritey = y + 0.5; + clist->sprites.spritex = x; + clist->sprites.spritey = y; return ; } x++; diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 0173fe6..0cd4cc6 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -45,22 +45,30 @@ void ft_calc_sprite(t_cub *cl) { t_sprite sprite; + static int i = 0; + float tmp_a; + float tmp_b; sprite = cl->sprites; - sprite.spritex = (sprite.spritex + 1) - cl->plist->pos_x; - sprite.spritey = (sprite.spritey + 1) - cl->plist->pos_y; - printf("%f%f\n", sprite.spritex, sprite.spritey); + tmp_a = cl->plist->dir_x; + tmp_b = cl->plist->dir_y; + sprite.spritex = sprite.spritex - (cl->plist->pos_x - 0.5); + sprite.spritey = sprite.spritey - (cl->plist->pos_y - 0.5); + printf("[%f] [%f] x [%f] y [%f] [%d]\n", sprite.spritex, sprite.spritey, cl->plist->dir_x, cl->plist->dir_y, i); sprite.invdet = 1.0 / (cl->plist->plane_x * cl->plist->dir_y - cl->plist->dir_x * cl->plist->plane_y); sprite.transformx = sprite.invdet * (cl->plist->dir_y * sprite.spritey - cl->plist->dir_x * sprite.spritex); sprite.transformy = sprite.invdet * (-cl->plist->plane_y * sprite.spritex + cl->plist->plane_x * sprite.spritey); - sprite.spritescreenx = (int)((cl->wlist->x_size / 2) * + sprite.spritescreenx = (int)((cl->wlist->y_size / 2) * (1 + sprite.transformx / sprite.transformy)); ft_sprite_height(cl, &sprite); ft_sprite_width(cl, &sprite); ft_draw_sprite(cl, &sprite); + cl->plist->dir_x = tmp_a; + cl->plist->dir_y = tmp_b; + i++; } void |