mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
Added a real rendering
This commit is contained in:
parent
3b495f213f
commit
4f573baf23
2 changed files with 14 additions and 5 deletions
3
Makefile
3
Makefile
|
|
@ -1,5 +1,6 @@
|
||||||
CC=cc
|
CC=cc
|
||||||
SANITIZERS=-fsanitize=address -fno-omit-frame-pointer
|
SANITIZERS=
|
||||||
|
#-fsanitize=address -fno-omit-frame-pointer
|
||||||
CFLAGS=-Wall -Wextra -Werror -g $(SANITIZERS) -I mlx
|
CFLAGS=-Wall -Wextra -Werror -g $(SANITIZERS) -I mlx
|
||||||
SOURCEFILES=src/main.c \
|
SOURCEFILES=src/main.c \
|
||||||
src/map/map_checker.c \
|
src/map/map_checker.c \
|
||||||
|
|
|
||||||
16
src/main.c
16
src/main.c
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
|
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
|
||||||
/* Updated: 2025/07/09 17:09:01 by tchampio ### ########.fr */
|
/* Updated: 2025/07/09 17:19:54 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -130,6 +130,16 @@ void init_player(t_mapdata *mapdata, t_player *player)
|
||||||
player->y = mapdata->starty;
|
player->y = mapdata->starty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int game_loop(t_cub3d_data *data)
|
||||||
|
{
|
||||||
|
data->player.x += data->player.movement.x;
|
||||||
|
data->player.y += data->player.movement.y;
|
||||||
|
mlx_clear_window(data->mlx, data->mlx_win);
|
||||||
|
draw_map(data->map, data->mlx_data);
|
||||||
|
mlx_put_image_to_window(data->mlx, data->mlx_win, data->mlx_data->img, 0, 0);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
t_cub3d_data data;
|
t_cub3d_data data;
|
||||||
|
|
@ -144,14 +154,12 @@ int main(int argc, char **argv)
|
||||||
data.mlx_data = ft_calloc(sizeof(t_mlx_data), 1);
|
data.mlx_data = ft_calloc(sizeof(t_mlx_data), 1);
|
||||||
data.mlx_data->img = mlx_new_image(data.mlx, 800, 600);
|
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);
|
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));
|
init_player(data.map, &(data.player));
|
||||||
draw_map(data.map, data.mlx_data);
|
|
||||||
mlx_hook(data.mlx_win, KeyPress, KeyPressMask, keypress_handler, &data);
|
mlx_hook(data.mlx_win, KeyPress, KeyPressMask, keypress_handler, &data);
|
||||||
mlx_hook(data.mlx_win, KeyRelease, KeyReleaseMask, keypress_handler, &data);
|
mlx_hook(data.mlx_win, KeyRelease, KeyReleaseMask, keypress_handler, &data);
|
||||||
mlx_put_image_to_window(data.mlx, data.mlx_win, data.mlx_data->img, 0, 0);
|
|
||||||
#ifdef BONUS
|
#ifdef BONUS
|
||||||
mlx_string_put(data.mlx, data.mlx_win, 10, 10, 0x00FFFFFF, "compiled with bonuses");
|
mlx_string_put(data.mlx, data.mlx_win, 10, 10, 0x00FFFFFF, "compiled with bonuses");
|
||||||
#endif
|
#endif
|
||||||
|
mlx_loop_hook(data.mlx, game_loop, &data);
|
||||||
mlx_loop(data.mlx);
|
mlx_loop(data.mlx);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue