mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: calculate distance to first horizontal line
This commit is contained in:
parent
76fba8fd8a
commit
d856a10ffc
2 changed files with 8 additions and 6 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:54:36 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/28 15:03:19 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/29 11:42:20 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
# define WIDTH 800
|
||||
|
||||
# define SIZE 64
|
||||
# define MAP_SIZE 10
|
||||
# define MAP_SIZE 20
|
||||
|
||||
extern const float g_north;
|
||||
extern const float g_south;
|
||||
|
|
|
|||
10
src/main.c
10
src/main.c
|
|
@ -139,13 +139,15 @@ int game_loop(t_cub3d_data *data)
|
|||
|
||||
printf("local coord: %f, %f\n", coord_global_to_local(data->player.x), coord_global_to_local(data->player.y));
|
||||
|
||||
float ray_angle = data->player.yaw - M_PI / 6;
|
||||
|
||||
/* float ray_angle = data->player.yaw - M_PI / 6; // 30 deg clockwise from player */
|
||||
float ray_angle = data->player.yaw; // straight ahead
|
||||
float fraction = M_PI / 3 / WIDTH;
|
||||
int column = 0;
|
||||
while (column < WIDTH)
|
||||
while (column < 1)
|
||||
{
|
||||
// hline check
|
||||
/* float ray_atan = atan(ray_angle); */
|
||||
float first_hline_distance = coord_global_to_local(data->player.y) / cos(ray_angle);
|
||||
printf("first hline distance: %f\n", first_hline_distance);
|
||||
draw_line(data, ray_angle);
|
||||
column++;
|
||||
ray_angle += fraction;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue