39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* create_grid.c :+: :+: */
|
|
/* +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/04/23 12:18:31 by whaffman #+# #+# */
|
|
/* Updated: 2025/04/23 12:20:25 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
#include "cub3d.h"
|
|
|
|
t_tile **create_grid(int width, int height)
|
|
{
|
|
t_tile **grid;
|
|
int i;
|
|
|
|
grid = malloc(sizeof(t_tile *) * height);
|
|
if (!grid)
|
|
return (NULL);
|
|
i = 0;
|
|
while (i < height)
|
|
{
|
|
grid[i] = malloc(sizeof(t_tile) * width);
|
|
if (!grid[i])
|
|
{
|
|
while (--i >= 0)
|
|
free(grid[i]);
|
|
free(grid);
|
|
return (NULL);
|
|
}
|
|
i++;
|
|
}
|
|
return (grid);
|
|
}
|