Archived
1
0

🏗️」 wip: Added line size calculus

This commit is contained in:
2024-10-13 17:49:01 +02:00
parent 24da8e8c27
commit da17af41b1
6 changed files with 55 additions and 11 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/07 16:55:09 by adjoly #+# #+# */
/* Updated: 2024/10/08 13:59:15 by adjoly ### ########.fr */
/* Updated: 2024/10/13 17:27:17 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,18 +18,18 @@ void dda(t_player *player, char **map)
t_dda dda[WINDOW_X / RAY_SIZE];
t_coord map_coord;
float *wall_dist;
float *line_size;
setup_dda(&dda, player);
map_coord.x = player->coords.x - player->coords.x % MAP_CHUNK_SIZE;
map_coord.y = player->coords.y - player->coords.y % MAP_CHUNK_SIZE;
while_dda(&dda, map, map_coord);
wall_dist = dist_dda(dda);
}
/**
* calculate size on screen
* screen_height / per_wall_dist
*
* print on screen
*
* (and get orientation)
*/

View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* line_dda.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/13 17:27:44 by adjoly #+# #+# */
/* Updated: 2024/10/13 17:36:05 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "game/settings.h"
uint16_t *line_dda(t_dda (*dda)[WINDOW_X / RAY_SIZE], float *wall_dist)
{
uint16_t i;
uint16_t *line_size;
(void)dda;
i = 0;
line_size = malloc(WINDOW_X / RAY_SIZE * sizeof(uint16_t));
while (wall_dist[i])
{
line_size[i] = (WINDOW_Y / wall_dist[i]);
i++;
}
return (line_size);
}