mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
???
This commit is contained in:
parent
83fc0d7d35
commit
a8abe903cb
7 changed files with 56 additions and 21 deletions
49
src/main.c
49
src/main.c
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
|
||||
/* Updated: 2025/07/02 15:32:23 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/07/05 10:30:03 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -27,10 +27,11 @@ void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
|
|||
}
|
||||
|
||||
void draw_2d_wall(unsigned int color, t_mlx_data *data,
|
||||
int size, int x, int y)
|
||||
int x, int y)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int i;
|
||||
int j;
|
||||
static int size = 20;
|
||||
|
||||
i = 0;
|
||||
while (i < size)
|
||||
|
|
@ -79,23 +80,49 @@ void draw_map(t_mapdata *map, t_mlx_data *data)
|
|||
while (map->map[i][j])
|
||||
{
|
||||
if (map->map[i][j] == '1')
|
||||
draw_2d_wall(map->f_color, data, 20, 20 * j, 20 * i);
|
||||
draw_2d_wall(map->f_color, data, 20 * j, 20 * i);
|
||||
else if (map->map[i][j] == 'Z' || map->map[i][j] == 'z')
|
||||
draw_2d_wall(0x0008D9D6, data, 20, 20 * j, 20 * i);
|
||||
draw_2d_wall(0x0008D9D6, data, 20 * j, 20 * i);
|
||||
else if (map->map[i][j] == 'D' || map->map[i][j] == 'd')
|
||||
draw_2d_wall(0x00FF2E63, data, 20, 20 * j, 20 * i);
|
||||
draw_2d_wall(0x00FF2E63, data, 20 * j, 20 * i);
|
||||
else if (map->map[i][j] == 's')
|
||||
draw_2d_wall(0x00E84545, data, 20, 20 * j, 20 * i);
|
||||
draw_2d_wall(0x00E84545, data, 20 * j, 20 * i);
|
||||
else if (map->map[i][j] == 'M')
|
||||
draw_2d_wall(0x00F4CE14, data, 20, 20 * j, 20 * i);
|
||||
draw_2d_wall(0x00F4CE14, data, 20 * j, 20 * i);
|
||||
else if (ft_strchr("NSEW", map->map[i][j]))
|
||||
draw_2d_wall(0x00FF0000, data, 20, 20 * j, 20 * i);
|
||||
draw_2d_wall(0x00FF0000, data, 20 * j, 20 * i);
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void init_player(t_mapdata *mapdata, t_player *player)
|
||||
{
|
||||
char facing;
|
||||
|
||||
facing = mapdata->map[mapdata->starty][mapdata->startx];
|
||||
player->health = 100;
|
||||
player->x = mapdata->startx;
|
||||
player->y = mapdata->starty;
|
||||
if (facing == 'N')
|
||||
player->yaw = 0;
|
||||
else if (facing == 'E')
|
||||
player->yaw = 90;
|
||||
else if (facing == 'S')
|
||||
player->yaw = 180;
|
||||
else if (facing == 'W')
|
||||
player->yaw = 270;
|
||||
else
|
||||
player->yaw = 0;
|
||||
}
|
||||
|
||||
void draw_player_pos(t_mapdata *map, t_mlx_data *data)
|
||||
{
|
||||
(void)data;
|
||||
ft_printf("position: %d %d\n", map->startx, map->starty);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
t_cub3d_data data;
|
||||
|
|
@ -111,7 +138,9 @@ int main(int argc, char **argv)
|
|||
data.mlx_data->img = mlx_new_image(data.mlx, 800, 600);
|
||||
data.mlx_data->addr = mlx_get_data_addr(data.mlx_data->img, &data.mlx_data->bits_per_pixel, &data.mlx_data->line_length, &data.mlx_data->endian);
|
||||
mlx_hook(data.mlx_win, 17, 0L, destroy, &data);
|
||||
init_player(data.map, &(data.player));
|
||||
draw_map(data.map, data.mlx_data);
|
||||
draw_player_pos(data.map, data.mlx_data);
|
||||
mlx_key_hook(data.mlx_win, key_destroy, &data);
|
||||
mlx_put_image_to_window(data.mlx, data.mlx_win, data.mlx_data->img, 0, 0);
|
||||
#ifdef BONUS
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/21 19:29:45 by tchampio #+# #+# */
|
||||
/* Updated: 2025/07/02 10:38:16 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/07/04 15:04:38 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@
|
|||
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/30 17:19:16 by tchampio #+# #+# */
|
||||
/* Updated: 2025/07/02 15:33:37 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/07/04 14:33:49 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/libft.h"
|
||||
#include "../../includes/maputils.h"
|
||||
|
||||
|
||||
#ifdef BONUS
|
||||
|
||||
bool has_forbidden_characters(char *line)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
|
||||
/* Updated: 2025/06/24 11:31:48 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/07/04 14:40:00 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -57,6 +57,8 @@ void flood_fill(t_mapdata *map, int x, int y)
|
|||
{
|
||||
if (map->mapflood[y][x] == '1')
|
||||
return ;
|
||||
if (map->mapflood[y][x] == 'z')
|
||||
return ;
|
||||
if (map->mapflood[y][x] == ' ' || map->mapflood[y][x] == '\n')
|
||||
map->isvalid = false;
|
||||
map->mapflood[y][x] = '1';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue