aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p1.le-101.fr>2020-03-08 19:14:51 +0100
committerRudy Bousset <rbousset@z2r4p1.le-101.fr>2020-03-08 19:14:51 +0100
commitab50e31ddbe77885bc2a517dfd239f88077ad77c (patch)
treee75334543161f6500e1d3d2ebe6ef3489fdcda44
parentJimi Hendrix would be proud (diff)
download42-cub3d-ab50e31ddbe77885bc2a517dfd239f88077ad77c.tar.gz
42-cub3d-ab50e31ddbe77885bc2a517dfd239f88077ad77c.tar.bz2
42-cub3d-ab50e31ddbe77885bc2a517dfd239f88077ad77c.tar.xz
42-cub3d-ab50e31ddbe77885bc2a517dfd239f88077ad77c.tar.zst
42-cub3d-ab50e31ddbe77885bc2a517dfd239f88077ad77c.zip
Something wrong
-rw-r--r--inc/cub3d_structs.h1
-rw-r--r--map/map_one.cub6
-rw-r--r--src/ft_draw_verline.c10
-rw-r--r--src/ft_floor_cast.c17
-rw-r--r--src/ft_raycasting.c6
5 files changed, 17 insertions, 23 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index 995ef08..7072628 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -122,7 +122,6 @@ typedef struct s_ray
{
uint16_t line_h;
float wall_dist;
- float perp_wall_dist;
float x_ray_pos;
float y_ray_pos;
float x_ray_dir;
diff --git a/map/map_one.cub b/map/map_one.cub
index c503a55..887e34f 100644
--- a/map/map_one.cub
+++ b/map/map_one.cub
@@ -9,10 +9,10 @@ S ./media/img/pillar.xpm
C 50,100,200
F 50,190,124
-11111111111111111
+111111111111111111
120000000011000001
-100102000000000001
-1N1100000111000001
+10010E000000000001
+101100000111000001
111111111111110011
1000001 100001
1001001 100001
diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c
index 5368c4e..7f0fd1c 100644
--- a/src/ft_draw_verline.c
+++ b/src/ft_draw_verline.c
@@ -43,15 +43,15 @@ static void
{
curr_dist = cl->wlist.y_size / (2.0 * y - cl->wlist.y_size);
weight = (curr_dist - dist_player)
- / (cl->rlist.perp_wall_dist - dist_player);
+ / (cl->rlist.wall_dist - dist_player);
curr_floor_x = weight * cl->rlist.floor_x_wall
+ (1.0 - weight) * cl->plist.pos_x;
curr_floor_y = weight * cl->rlist.floor_y_wall
+ (1.0 - weight) * cl->plist.pos_y;
- cl->tlist[6].tex_x = (int32_t)(curr_floor_x
- * cl->tlist[6].img_w) % cl->tlist[6].img_w;
- cl->tlist[6].tex_y = (int32_t)(curr_floor_y
- * cl->tlist[6].img_h) % cl->tlist[6].img_h;
+ cl->tlist[6].tex_x = (int32_t)(curr_floor_x * cl->tlist[6].img_w)
+ % cl->tlist[6].img_w;
+ cl->tlist[6].tex_y = (int32_t)(curr_floor_y * cl->tlist[6].img_h)
+ % cl->tlist[6].img_h;
/* cl->tlist[6].tex_x = (cl->tlist[6].tex_x > 0) */
/* ? (cl->tlist[6].tex_x) : (-cl->tlist[6].tex_x); */
/* cl->tlist[6].tex_y = (cl->tlist[6].tex_y > 0) */
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index fe2734a..3343fc3 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -13,6 +13,7 @@
#include <cub3d.h>
#include <stdint.h>
+#include <stdio.h>
void
ft_floor_cast(t_cub *cl)
{
@@ -23,22 +24,22 @@ void
rl = &cl->rlist;
if (rl->side == 0 && rl->x_ray_dir > 0)
{
- rl->floor_x_wall = (float)map_x;
- rl->floor_y_wall = (float)map_y + rl->wall_hit_x;
+ rl->floor_x_wall = map_x;
+ rl->floor_y_wall = map_y + rl->wall_hit_x;
}
else if (rl->side == 0 && rl->x_ray_dir < 0)
{
- rl->floor_x_wall = (float)map_x + 1.0;
- rl->floor_y_wall = (float)map_y + rl->wall_hit_x;
+ rl->floor_x_wall = map_x + 1.0;
+ rl->floor_y_wall = map_y + rl->wall_hit_x;
}
else if (rl->side == 1 && rl->y_ray_dir > 0)
{
- rl->floor_x_wall = (float)map_x + rl->wall_hit_x;
- rl->floor_y_wall = (float)map_y;
+ rl->floor_x_wall = map_x + rl->wall_hit_x;
+ rl->floor_y_wall = map_y;
}
else
{
- rl->floor_x_wall = (float)map_x + rl->wall_hit_x;
- rl->floor_y_wall = (float)map_y + 1.0;
+ rl->floor_x_wall = map_x + rl->wall_hit_x;
+ rl->floor_y_wall = map_y + 1.0;
}
}
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 121e132..0a4b8b5 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -74,12 +74,6 @@ void
else if (clist->rlist.side == 1 && clist->rlist.y_ray_dir < 0)
clist->tlist[clist->w_side].tex_x = clist->tlist[clist->w_side].img_w
- clist->tlist[clist->w_side].tex_x - 1;
- if (clist->rlist.side == 0)
- clist->rlist.perp_wall_dist = ((uint32_t)clist->plist.pos_x
- - clist->plist.pos_x + (1 - clist->mlist.x_step) / 2) / clist->rlist.x_ray_dir;
- else
- clist->rlist.perp_wall_dist = ((uint32_t)clist->plist.pos_y
- - clist->plist.pos_y + (1 - clist->mlist.y_step) / 2) / clist->rlist.y_ray_dir;
}
static void