Merge branch 'willem_extra' into willem
This commit is contained in:
commit
0a5355b13f
BIN
assets/overlay.png
Normal file
BIN
assets/overlay.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 MiB |
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* collision.c :+: :+: :+: */
|
/* collision.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 14:40:59 by qmennen #+# #+# */
|
/* Created: 2025/04/22 14:40:59 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:33:06 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/23 12:23:05 by whaffman #+# #+# */
|
/* Created: 2025/04/23 12:23:05 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/23 12:23:14 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:51:33 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/23 12:20:38 by whaffman #+# #+# */
|
/* Created: 2025/04/23 12:20:38 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/23 12:21:00 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:21:14 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -21,8 +21,12 @@ void grid_free(t_tile **grid, int height)
|
|||||||
return ;
|
return ;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < height)
|
while (i < height)
|
||||||
|
{
|
||||||
|
if (grid[i])
|
||||||
{
|
{
|
||||||
free(grid[i]);
|
free(grid[i]);
|
||||||
|
grid[i] = NULL;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
free(grid);
|
free(grid);
|
||||||
|
|||||||
@ -1,18 +1,17 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* map_create.c :+: :+: :+: */
|
/* map_create.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/23 12:21:13 by whaffman #+# #+# */
|
/* Created: 2025/04/23 12:21:13 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/05/06 16:00:10 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:52:14 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "cub3d.h"
|
#include "cub3d.h"
|
||||||
|
|
||||||
|
|
||||||
int map_create(t_game **game, const char *mapfile)
|
int map_create(t_game **game, const char *mapfile)
|
||||||
{
|
{
|
||||||
t_tile **grid;
|
t_tile **grid;
|
||||||
@ -26,7 +25,8 @@ int map_create(t_game **game, const char *mapfile)
|
|||||||
return (FAILURE);
|
return (FAILURE);
|
||||||
}
|
}
|
||||||
ft_memset((*game)->map->textures, 0, sizeof((*game)->map->textures));
|
ft_memset((*game)->map->textures, 0, sizeof((*game)->map->textures));
|
||||||
parse_args(mapfile, (*game));
|
if (!parse_args(mapfile, (*game)))
|
||||||
|
return (FAILURE);
|
||||||
grid = copy_map((*game)->map->grid, (*game)->map->width, (*game)->map->height);
|
grid = copy_map((*game)->map->grid, (*game)->map->width, (*game)->map->height);
|
||||||
if (!grid)
|
if (!grid)
|
||||||
{
|
{
|
||||||
@ -44,6 +44,5 @@ int map_create(t_game **game, const char *mapfile)
|
|||||||
grid_free((*game)->map->grid, (*game)->map->height);
|
grid_free((*game)->map->grid, (*game)->map->height);
|
||||||
(*game)->map->grid = grid;
|
(*game)->map->grid = grid;
|
||||||
print_config((*game)->map);
|
print_config((*game)->map);
|
||||||
|
|
||||||
return (SUCCESS);
|
return (SUCCESS);
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/23 12:22:28 by whaffman #+# #+# */
|
/* Created: 2025/04/23 12:22:28 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/23 12:22:49 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:51:46 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -16,7 +16,6 @@
|
|||||||
void map_free(t_map *map)
|
void map_free(t_map *map)
|
||||||
{
|
{
|
||||||
grid_free(map->grid, map->height);
|
grid_free(map->grid, map->height);
|
||||||
// free(map->grid);
|
|
||||||
free(map->NO_texture);
|
free(map->NO_texture);
|
||||||
free(map->SO_texture);
|
free(map->SO_texture);
|
||||||
free(map->WE_texture);
|
free(map->WE_texture);
|
||||||
|
|||||||
@ -6,14 +6,13 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 09:54:24 by whaffman #+# #+# */
|
/* Created: 2025/04/25 09:54:24 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/25 10:39:42 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:49:58 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "cub3d.h"
|
#include "cub3d.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
|
|
||||||
t_vec2 add(t_vec2 a, t_vec2 b)
|
t_vec2 add(t_vec2 a, t_vec2 b)
|
||||||
{
|
{
|
||||||
t_vec2 result;
|
t_vec2 result;
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* dist.c :+: :+: :+: */
|
/* dist.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 10:07:59 by whaffman #+# #+# */
|
/* Created: 2025/04/25 10:07:59 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:50:10 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* dist_point_line.c :+: :+: :+: */
|
/* dist_point_line.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 10:09:45 by whaffman #+# #+# */
|
/* Created: 2025/04/25 10:09:45 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:50:20 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* dot.c :+: :+: :+: */
|
/* dot.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 09:58:29 by whaffman #+# #+# */
|
/* Created: 2025/04/25 09:58:29 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:50:27 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* mul.c :+: :+: :+: */
|
/* mul.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 09:56:39 by whaffman #+# #+# */
|
/* Created: 2025/04/25 09:56:39 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:50:43 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* norm.c :+: :+: :+: */
|
/* norm.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 09:59:13 by whaffman #+# #+# */
|
/* Created: 2025/04/25 09:59:13 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:50:52 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 10:34:39 by whaffman #+# #+# */
|
/* Created: 2025/04/25 10:34:39 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/25 10:40:17 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:50:59 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* rot.c :+: :+: :+: */
|
/* rot.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 10:35:58 by whaffman #+# #+# */
|
/* Created: 2025/04/25 10:35:58 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:51:19 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/25 09:57:55 by whaffman #+# #+# */
|
/* Created: 2025/04/25 09:57:55 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/25 10:40:27 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:51:07 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:02:31 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:02:31 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:03:03 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:47:41 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:04:07 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:04:07 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:06:41 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:47:48 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:08:26 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:08:26 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:08:37 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:48:11 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:13:07 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:13:07 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:19:40 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:48:00 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:08:52 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:08:52 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:09:33 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:47:55 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -26,7 +26,6 @@ unsigned int parse_color(const char *color_str)
|
|||||||
|| !(tokens[2] && ft_strlen(tokens[2]) <= 3)
|
|| !(tokens[2] && ft_strlen(tokens[2]) <= 3)
|
||||||
|| tokens[3])
|
|| tokens[3])
|
||||||
return (FAILURE);
|
return (FAILURE);
|
||||||
|
|
||||||
r = ft_atoi(tokens[0]);
|
r = ft_atoi(tokens[0]);
|
||||||
g = ft_atoi(tokens[1]);
|
g = ft_atoi(tokens[1]);
|
||||||
b = ft_atoi(tokens[2]);
|
b = ft_atoi(tokens[2]);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:10:06 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:10:06 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:10:23 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:48:16 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:11:37 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:11:37 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/25 11:38:44 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:48:25 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* parse_map.c :+: :+: :+: */
|
/* parse_map.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:12:04 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:12:04 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:49:18 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -27,9 +27,13 @@ int parse_player(t_game *game, int y, int x, char c)
|
|||||||
t_player *player;
|
t_player *player;
|
||||||
|
|
||||||
player = game->player;
|
player = game->player;
|
||||||
|
if (player->pos.x != -1 || player->pos.y != -1)
|
||||||
|
{
|
||||||
|
ft_putstr_fd("Error: Multiple players found\n", 2);
|
||||||
|
return (FAILURE);
|
||||||
|
}
|
||||||
player->pos.x = ((double)x + 0.5f);
|
player->pos.x = ((double)x + 0.5f);
|
||||||
player->pos.y = ((double)y + 0.5f);
|
player->pos.y = ((double)y + 0.5f);
|
||||||
|
|
||||||
if (c == 'N')
|
if (c == 'N')
|
||||||
player->dir = parse_dir(0, -1);
|
player->dir = parse_dir(0, -1);
|
||||||
else if (c == 'E')
|
else if (c == 'E')
|
||||||
@ -38,7 +42,6 @@ int parse_player(t_game *game, int y, int x, char c)
|
|||||||
player->dir = parse_dir(0, 1);
|
player->dir = parse_dir(0, 1);
|
||||||
else if (c == 'W')
|
else if (c == 'W')
|
||||||
player->dir = parse_dir(-1, 0);
|
player->dir = parse_dir(-1, 0);
|
||||||
|
|
||||||
player->camera = rot(player->dir, 0.5f * M_PI);
|
player->camera = rot(player->dir, 0.5f * M_PI);
|
||||||
return (SUCCESS);
|
return (SUCCESS);
|
||||||
}
|
}
|
||||||
@ -60,9 +63,10 @@ int parse_map_line(char **lines, t_game *game, int y)
|
|||||||
else
|
else
|
||||||
map->grid[y][x] = parse_tile(lines[y][x]);
|
map->grid[y][x] = parse_tile(lines[y][x]);
|
||||||
if (map->grid[y][x] == TILE_PLAYER)
|
if (map->grid[y][x] == TILE_PLAYER)
|
||||||
parse_player(game, y, x, lines[y][x]);
|
{
|
||||||
else if (map->grid[y][x] == -2)
|
if (!parse_player(game, y, x, lines[y][x]))
|
||||||
return (FAILURE);
|
return (FAILURE);
|
||||||
|
}
|
||||||
if (map->grid[y][x] == -2)
|
if (map->grid[y][x] == -2)
|
||||||
return (FAILURE);
|
return (FAILURE);
|
||||||
x++;
|
x++;
|
||||||
@ -84,13 +88,13 @@ int parse_map(char **lines, t_game *game)
|
|||||||
map->grid = malloc(sizeof(t_tile *) * (map->height + 1));
|
map->grid = malloc(sizeof(t_tile *) * (map->height + 1));
|
||||||
if (!map->grid)
|
if (!map->grid)
|
||||||
return (FAILURE);
|
return (FAILURE);
|
||||||
|
ft_memset(map->grid, 0, sizeof(t_tile *) * (map->height + 1));
|
||||||
y = 0;
|
y = 0;
|
||||||
while (y < map->height)
|
while (y < map->height)
|
||||||
{
|
{
|
||||||
if (!parse_map_line(lines, game, y))
|
if (!parse_map_line(lines, game, y))
|
||||||
return (map_free(map), FAILURE);
|
return (FAILURE);
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
map->grid[y] = NULL;
|
|
||||||
return (SUCCESS);
|
return (SUCCESS);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:12:31 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:12:31 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:12:56 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:48:30 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:03:24 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:03:24 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:17:28 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:48:40 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:11:18 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:11:18 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:11:28 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:49:07 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -24,6 +24,5 @@ void print_config(t_map *map)
|
|||||||
printf("Floor color: %u\n", map->floor_color);
|
printf("Floor color: %u\n", map->floor_color);
|
||||||
printf("Ceiling color: %u\n", map->ceiling_color);
|
printf("Ceiling color: %u\n", map->ceiling_color);
|
||||||
printf("Grid:\n");
|
printf("Grid:\n");
|
||||||
|
|
||||||
print_map(map);
|
print_map(map);
|
||||||
}
|
}
|
||||||
@ -6,11 +6,10 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 13:07:09 by whaffman #+# #+# */
|
/* Created: 2025/04/22 13:07:09 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:07:56 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:49:04 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,8 @@ int player_create(t_game **game)
|
|||||||
player = malloc(sizeof(t_player));
|
player = malloc(sizeof(t_player));
|
||||||
if (!player)
|
if (!player)
|
||||||
return (FAILURE);
|
return (FAILURE);
|
||||||
player->pos.x = 1;
|
player->pos.x = -1;
|
||||||
player->pos.y = 1;
|
player->pos.y = -1;
|
||||||
player->dir.x = 1;
|
player->dir.x = 1;
|
||||||
player->dir.y = 0;
|
player->dir.y = 0;
|
||||||
player->camera.x = 0;
|
player->camera.x = 0;
|
||||||
@ -91,7 +91,8 @@ void player_render(t_screen *screen, t_player *player)
|
|||||||
{
|
{
|
||||||
t_vec2 direction;
|
t_vec2 direction;
|
||||||
|
|
||||||
if (player->pos.x < 0 || player->pos.x >= screen->width || player->pos.y < 0 || player->pos.y >= screen->height)
|
if (player->pos.x < 0 || player->pos.x >= screen->width
|
||||||
|
|| player->pos.y < 0 || player->pos.y >= screen->height)
|
||||||
return ;
|
return ;
|
||||||
render_circle(screen, mul(player->pos, TILE_SIZE), 4, 0x111111ff);
|
render_circle(screen, mul(player->pos, TILE_SIZE), 4, 0x111111ff);
|
||||||
direction = add(mul(player->pos, TILE_SIZE), mul(player->dir, TILE_SIZE));
|
direction = add(mul(player->pos, TILE_SIZE), mul(player->dir, TILE_SIZE));
|
||||||
|
|||||||
@ -22,7 +22,6 @@ t_vec2 get_delta_dist(t_vec2 ray_dir)
|
|||||||
delta_dist.x = 1e30;
|
delta_dist.x = 1e30;
|
||||||
else
|
else
|
||||||
delta_dist.x = fabs(1 / ray_dir.x);
|
delta_dist.x = fabs(1 / ray_dir.x);
|
||||||
|
|
||||||
if (ray_dir.y == 0)
|
if (ray_dir.y == 0)
|
||||||
delta_dist.y = 1e30;
|
delta_dist.y = 1e30;
|
||||||
else
|
else
|
||||||
@ -46,8 +45,10 @@ t_vec2 get_side_dist(t_vec2 ray_dir, t_vec2 pos, t_vec2 delta_dist)
|
|||||||
const int raydir_y_pos = (ray_dir.y >= 0);
|
const int raydir_y_pos = (ray_dir.y >= 0);
|
||||||
t_vec2 side_dist;
|
t_vec2 side_dist;
|
||||||
|
|
||||||
side_dist.x = ((1 - raydir_x_pos) * frac_pos.x + raydir_x_pos * (1 - frac_pos.x)) * delta_dist.x;
|
side_dist.x = ((1 - raydir_x_pos) * frac_pos.x
|
||||||
side_dist.y = ((1 - raydir_y_pos) * frac_pos.y + raydir_y_pos * (1 - frac_pos.y)) * delta_dist.y;
|
+ raydir_x_pos * (1 - frac_pos.x)) * delta_dist.x;
|
||||||
|
side_dist.y = ((1 - raydir_y_pos) * frac_pos.y
|
||||||
|
+ raydir_y_pos * (1 - frac_pos.y)) * delta_dist.y;
|
||||||
return (side_dist);
|
return (side_dist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +67,10 @@ int dda_main(t_vec2 ray_dir, t_vec2_int map_pos, t_vec2 *side_dist, t_map *map)
|
|||||||
side_dist->y += delta_dist.y * side;
|
side_dist->y += delta_dist.y * side;
|
||||||
map_pos.x += step.x * (1 - side);
|
map_pos.x += step.x * (1 - side);
|
||||||
map_pos.y += step.y * side;
|
map_pos.y += step.y * side;
|
||||||
if (map_pos.x < 0 || map_pos.x >= map->width || map_pos.y < 0 || map_pos.y >= map->height)
|
if (map_pos.x < 0
|
||||||
|
|| map_pos.x >= map->width
|
||||||
|
|| map_pos.y < 0
|
||||||
|
|| map_pos.y >= map->height)
|
||||||
printf("Out of bounds: %d %d\n", map_pos.x, map_pos.y);
|
printf("Out of bounds: %d %d\n", map_pos.x, map_pos.y);
|
||||||
hit = (map->grid[map_pos.y][map_pos.x] == TILE_WALL);
|
hit = (map->grid[map_pos.y][map_pos.x] == TILE_WALL);
|
||||||
}
|
}
|
||||||
@ -87,7 +91,8 @@ double dda(t_vec2 ray_dir, t_vec2 pos, t_map *map)
|
|||||||
(t_vec2_int){(int)pos.x, (int)pos.y},
|
(t_vec2_int){(int)pos.x, (int)pos.y},
|
||||||
&side_dist,
|
&side_dist,
|
||||||
map);
|
map);
|
||||||
return ((1 - side) * (side_dist.x - delta_dist.x) - side * (side_dist.y - delta_dist.y));
|
return ((1 - side) * (side_dist.x - delta_dist.x)
|
||||||
|
- side * (side_dist.y - delta_dist.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
t_side get_side(t_vec2 ray_dir, double perp_dist)
|
t_side get_side(t_vec2 ray_dir, double perp_dist)
|
||||||
@ -130,48 +135,53 @@ t_render cast_ray(t_game *game, int x)
|
|||||||
return (render);
|
return (render);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int get_texture_color(mlx_texture_t *texture, t_render render, int tex_x, int tex_y)
|
unsigned int get_texture_color(mlx_texture_t *texture,
|
||||||
|
t_render render, int tex_x, int tex_y)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
double dist;
|
double dist;
|
||||||
|
|
||||||
index = (tex_x + tex_y * texture->height) * texture->bytes_per_pixel;
|
index = (tex_x + tex_y * texture->height) * texture->bytes_per_pixel;
|
||||||
dist = (render.perp_dist == 0) * 1e30 + (render.perp_dist > 1) * render.perp_dist + (render.perp_dist <= 1) * 1;
|
dist = (render.perp_dist == 0) * 1e30
|
||||||
return texture->pixels[index] << 24 | texture->pixels[index + 1] << 16 | texture->pixels[index + 2] << 8 | (int)(1.0 / dist * 255);
|
+ (render.perp_dist > 1) * render.perp_dist
|
||||||
|
+ (render.perp_dist <= 1) * 1;
|
||||||
|
return (texture->pixels[index] << 24
|
||||||
|
| texture->pixels[index + 1] << 16
|
||||||
|
| texture->pixels[index + 2] << 8
|
||||||
|
| (int)(1.0 / dist * 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_line(t_game *game, t_render render, int x)
|
void draw_line(t_game *game, t_render render, int x)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
int color;
|
int color;
|
||||||
int lineHeight;
|
int height;
|
||||||
int drawStart;
|
int start;
|
||||||
int texDrawStart;
|
int tex_start;
|
||||||
int drawEnd;
|
int end;
|
||||||
int tex_x;
|
int tex_x;
|
||||||
int tex_y;
|
int tex_y;
|
||||||
|
|
||||||
lineHeight = (int)(game->screen->height / render.perp_dist);
|
height = (int)(game->screen->height / render.perp_dist);
|
||||||
drawStart = -lineHeight / 2 + game->screen->height / 2;
|
start = -height / 2 + game->screen->height / 2;
|
||||||
texDrawStart = drawStart;
|
tex_start = start;
|
||||||
if (drawStart < 0)
|
if (start < 0)
|
||||||
drawStart = 0;
|
start = 0;
|
||||||
drawEnd = lineHeight / 2 + game->screen->height / 2;
|
end = height / 2 + game->screen->height / 2;
|
||||||
if (drawEnd >= game->screen->height)
|
if (end >= game->screen->height)
|
||||||
drawEnd = game->screen->height - 1;
|
end = game->screen->height - 1;
|
||||||
tex_x = (int)(render.wall_x * (double)game->map->textures[render.side]->width);
|
tex_x = (int)(render.wall_x * (double)game->map->textures[render.side]->width);
|
||||||
if (render.side == SIDE_NORTH || render.side == SIDE_EAST)
|
if (render.side == SIDE_NORTH || render.side == SIDE_EAST)
|
||||||
tex_x = game->map->textures[render.side]->width - tex_x - 1;
|
tex_x = game->map->textures[render.side]->width - tex_x - 1;
|
||||||
y = drawStart;
|
y = start;
|
||||||
while (y < drawEnd)
|
while (y < end)
|
||||||
{
|
{
|
||||||
tex_y = (int)(((double) game->map->textures[render.side]->height / (double) lineHeight) * (y - texDrawStart));
|
tex_y = (int)(((double) game->map->textures[render.side]->height / (double) height) * (y - tex_start));
|
||||||
color = get_texture_color(game->map->textures[render.side], render, tex_x, tex_y);
|
color = get_texture_color(game->map->textures[render.side], render, tex_x, tex_y);
|
||||||
if (x < 0 || x >= game->screen->width || y < 0 || y >= game->screen->height)
|
if (x < 0 || x >= game->screen->width || y < 0 || y >= game->screen->height)
|
||||||
break ;
|
break ;
|
||||||
mlx_put_pixel(game->screen->img, x, y, color);
|
mlx_put_pixel(game->screen->img, x, y, color);
|
||||||
y++;
|
y++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +204,6 @@ void draw_floor(t_game *game)
|
|||||||
row_dist = 0.5 * game->screen->height / (y - game->screen->height / 2.0);
|
row_dist = 0.5 * game->screen->height / (y - game->screen->height / 2.0);
|
||||||
floor_step = mul(mul(sub(right_ray, left_ray), row_dist), 1.0 / game->screen->width);
|
floor_step = mul(mul(sub(right_ray, left_ray), row_dist), 1.0 / game->screen->width);
|
||||||
floor_pos = add(game->player->pos, mul(left_ray, row_dist));
|
floor_pos = add(game->player->pos, mul(left_ray, row_dist));
|
||||||
|
|
||||||
x = 0;
|
x = 0;
|
||||||
while (x < game->screen->width)
|
while (x < game->screen->width)
|
||||||
{
|
{
|
||||||
@ -226,4 +235,3 @@ void cast_rays(t_game *game)
|
|||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* render.c :+: :+: :+: */
|
/* render.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/15 16:28:10 by qmennen #+# #+# */
|
/* Created: 2025/04/15 16:28:10 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/06 19:02:53 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:38:34 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,7 +15,10 @@
|
|||||||
|
|
||||||
int render_check_bounds(t_screen *screen, t_vec2 *point)
|
int render_check_bounds(t_screen *screen, t_vec2 *point)
|
||||||
{
|
{
|
||||||
return (point->x >= 0 && point->x < screen->width && point->y > 0 && point->y < screen->height);
|
return (point->x >= 0
|
||||||
|
&& point->x < screen->width
|
||||||
|
&& point->y > 0
|
||||||
|
&& point->y < screen->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_tile(t_screen *screen, int x, int y, t_tile tile)
|
void render_tile(t_screen *screen, int x, int y, t_tile tile)
|
||||||
@ -37,7 +40,6 @@ void render_tile(t_screen *screen, int x, int y, t_tile tile)
|
|||||||
mlx_put_pixel(screen->minimap, xp, yp, 0xA88132aa);
|
mlx_put_pixel(screen->minimap, xp, yp, 0xA88132aa);
|
||||||
else if (tile == TILE_EMPTY || tile == TILE_PLAYER)
|
else if (tile == TILE_EMPTY || tile == TILE_PLAYER)
|
||||||
mlx_put_pixel(screen->minimap, xp, yp, 0xaaaaaa44);
|
mlx_put_pixel(screen->minimap, xp, yp, 0xaaaaaa44);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ void render_map(t_screen *screen, t_map *map)
|
|||||||
int i;
|
int i;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < map->width * map->height)
|
while (i < map->width * map->height)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,13 +6,14 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/17 20:06:19 by qmennen #+# #+# */
|
/* Created: 2025/04/17 20:06:19 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/04 16:55:14 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:37:29 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
void render_circle(t_screen *screen, t_vec2 point, int radius, unsigned int color)
|
void render_circle(t_screen *screen,
|
||||||
|
t_vec2 point, int radius, unsigned int color)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int size;
|
int size;
|
||||||
@ -26,7 +27,8 @@ void render_circle(t_screen *screen, t_vec2 point, int radius, unsigned int colo
|
|||||||
x = i % size - radius;
|
x = i % size - radius;
|
||||||
y = i / size - radius;
|
y = i / size - radius;
|
||||||
if (x * x + y * y <= radius * radius)
|
if (x * x + y * y <= radius * radius)
|
||||||
mlx_put_pixel(screen->minimap, (int) point.x + x, (int) point.y + y, color);
|
mlx_put_pixel(screen->minimap,
|
||||||
|
(int) point.x + x, (int) point.y + y, color);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/17 20:05:51 by qmennen #+# #+# */
|
/* Created: 2025/04/17 20:05:51 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/04 16:55:44 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:37:36 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -18,6 +18,6 @@ void render_clear(t_screen *screen)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i++ < screen->width * screen->height)
|
while (i++ < screen->width * screen->height)
|
||||||
mlx_put_pixel(screen->minimap, i % screen->width, i / screen->width, 0x0);
|
mlx_put_pixel(screen->minimap,
|
||||||
|
i % screen->width, i / screen->width, 0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,17 +6,18 @@
|
|||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/17 20:06:40 by qmennen #+# #+# */
|
/* Created: 2025/04/17 20:06:40 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/04 16:56:16 by whaffman ######## odam.nl */
|
/* Updated: 2025/05/07 11:36:57 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
static void line_low(t_screen *screen, t_vec2 start, t_vec2 end, unsigned int color)
|
static void line_low(t_screen *screen,
|
||||||
|
t_vec2 start, t_vec2 end, unsigned int color)
|
||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
int yi;
|
int yi;
|
||||||
t_vec2 current;
|
t_vec2 cur;
|
||||||
t_vec2 delta_point;
|
t_vec2 delta_point;
|
||||||
|
|
||||||
delta_point.x = end.x - start.x;
|
delta_point.x = end.x - start.x;
|
||||||
@ -25,26 +26,27 @@ static void line_low(t_screen *screen, t_vec2 start, t_vec2 end, unsigned int co
|
|||||||
if (end.y - start.y < 0)
|
if (end.y - start.y < 0)
|
||||||
yi = -1;
|
yi = -1;
|
||||||
delta = 2 * delta_point.y - delta_point.x;
|
delta = 2 * delta_point.y - delta_point.x;
|
||||||
current = start;
|
cur = start;
|
||||||
while (current.x <= end.x)
|
while (cur.x <= end.x)
|
||||||
{
|
{
|
||||||
if (render_check_bounds(screen, ¤t))
|
if (render_check_bounds(screen, &cur))
|
||||||
mlx_put_pixel(screen->minimap, (int)current.x, (int)current.y, color);
|
mlx_put_pixel(screen->minimap, (int)cur.x, (int)cur.y, color);
|
||||||
if (delta > 0)
|
if (delta > 0)
|
||||||
{
|
{
|
||||||
current.y += yi;
|
cur.y += yi;
|
||||||
delta -= 2 * delta_point.x;
|
delta -= 2 * delta_point.x;
|
||||||
}
|
}
|
||||||
delta += 2 * delta_point.y;
|
delta += 2 * delta_point.y;
|
||||||
current.x++;
|
cur.x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void line_high(t_screen *screen, t_vec2 start, t_vec2 end, unsigned int color)
|
static void line_high(t_screen *screen,
|
||||||
|
t_vec2 start, t_vec2 end, unsigned int color)
|
||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
int xi;
|
int xi;
|
||||||
t_vec2 current;
|
t_vec2 cur;
|
||||||
t_vec2 delta_point;
|
t_vec2 delta_point;
|
||||||
|
|
||||||
delta_point.x = abs((int) end.x - (int) start.x);
|
delta_point.x = abs((int) end.x - (int) start.x);
|
||||||
@ -53,22 +55,23 @@ static void line_high(t_screen *screen, t_vec2 start, t_vec2 end, unsigned int c
|
|||||||
if (end.x - start.x < 0)
|
if (end.x - start.x < 0)
|
||||||
xi = -1;
|
xi = -1;
|
||||||
delta = 2 * delta_point.x - delta_point.y;
|
delta = 2 * delta_point.x - delta_point.y;
|
||||||
current = start;
|
cur = start;
|
||||||
while (current.y <= end.y)
|
while (cur.y <= end.y)
|
||||||
{
|
{
|
||||||
if (render_check_bounds(screen, ¤t))
|
if (render_check_bounds(screen, &cur))
|
||||||
mlx_put_pixel(screen->minimap, (int)current.x, (int)current.y, color);
|
mlx_put_pixel(screen->minimap, (int)cur.x, (int)cur.y, color);
|
||||||
if (delta > 0)
|
if (delta > 0)
|
||||||
{
|
{
|
||||||
current.x += xi;
|
cur.x += xi;
|
||||||
delta -= 2 * delta_point.y;
|
delta -= 2 * delta_point.y;
|
||||||
}
|
}
|
||||||
delta += 2 * delta_point.x;
|
delta += 2 * delta_point.x;
|
||||||
current.y++;
|
cur.y++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_line(t_screen *screen, t_vec2 start, t_vec2 end, unsigned int color)
|
void render_line(t_screen *screen,
|
||||||
|
t_vec2 start, t_vec2 end, unsigned int color)
|
||||||
{
|
{
|
||||||
if ((start.x < 0 || start.x >= (int) screen->img->width
|
if ((start.x < 0 || start.x >= (int) screen->img->width
|
||||||
|| start.y < 0 || start.y >= (int) screen->img->height)
|
|| start.y < 0 || start.y >= (int) screen->img->height)
|
||||||
|
|||||||
@ -63,6 +63,8 @@ int screen_display(t_screen *screen)
|
|||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
int m_height;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_width = 0;
|
m_width = 0;
|
||||||
m_height = 0;
|
m_height = 0;
|
||||||
fill_background(screen, 0x000000FF);
|
fill_background(screen, 0x000000FF);
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* texutre_load.c :+: :+: :+: */
|
/* texutre_load.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/05/06 15:45:58 by qmennen #+# #+# */
|
/* Created: 2025/05/06 15:45:58 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/06 19:01:15 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:49:37 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* errors.c :+: :+: :+: */
|
/* errors.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/15 15:40:14 by qmennen #+# #+# */
|
/* Created: 2025/04/15 15:40:14 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/04/15 16:10:57 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:34:57 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "MLX42.h"
|
#include "MLX42.h"
|
||||||
#include "cub3d.h"
|
#include "cub3d.h"
|
||||||
|
|
||||||
const char *last_error()
|
const char *last_error(void)
|
||||||
{
|
{
|
||||||
if (mlx_errno > 0)
|
if (mlx_errno > 0)
|
||||||
return (mlx_strerror(mlx_errno));
|
return (mlx_strerror(mlx_errno));
|
||||||
@ -26,6 +26,7 @@ const char *last_error()
|
|||||||
void game_error(t_game *game, const char *msg)
|
void game_error(t_game *game, const char *msg)
|
||||||
{
|
{
|
||||||
const char *last_err = last_error();
|
const char *last_err = last_error();
|
||||||
|
|
||||||
if (msg == NULL && last_err)
|
if (msg == NULL && last_err)
|
||||||
printf(RED"%s\n"RESET, last_err);
|
printf(RED"%s\n"RESET, last_err);
|
||||||
else
|
else
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* initialize.c :+: :+: :+: */
|
/* initialize.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/22 17:08:26 by qmennen #+# #+# */
|
/* Created: 2025/04/22 17:08:26 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/06 16:18:44 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:35:18 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* :::::::: */
|
||||||
/* keyboard.c :+: :+: :+: */
|
/* keyboard.c :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ */
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/04/17 19:29:29 by qmennen #+# #+# */
|
/* Created: 2025/04/17 19:29:29 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/04/22 14:46:18 by qmennen ### ########.fr */
|
/* Updated: 2025/05/07 11:35:41 by whaffman ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ void keyboard_update(t_game *game)
|
|||||||
|
|
||||||
int get_key(t_game *game, int k)
|
int get_key(t_game *game, int k)
|
||||||
{
|
{
|
||||||
return mlx_is_key_down(game->screen->mlx, k);
|
return (mlx_is_key_down(game->screen->mlx, k));
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_key_down(t_game *game, int k)
|
int get_key_down(t_game *game, int k)
|
||||||
|
|||||||
2
test.cub
2
test.cub
@ -19,7 +19,7 @@ C 100,100,200
|
|||||||
1000001110000001110011111111 110000001000000001
|
1000001110000001110011111111 110000001000000001
|
||||||
1000001 10001000000010000001 100000001000000001
|
1000001 10001000000010000001 100000001000000001
|
||||||
1000001110001000000000000001111100000001000000001
|
1000001110001000000000000001111100000001000000001
|
||||||
100W000000001111111111100000000000111111000000001
|
1000000000001111111111100000000000111111000000001
|
||||||
1000000W00001 1000011111111 1000001001
|
1000000W00001 1000011111111 1000001001
|
||||||
1000011111001 111111100001 1111111111110001
|
1000011111001 111111100001 1111111111110001
|
||||||
100001 1001 1000000000011111111000010111 10001
|
100001 1001 1000000000011111111000010111 10001
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user