This commit is contained in:
Willem Haffmans 2025-05-29 09:53:10 +02:00
parent fb1e7979d9
commit d8bef01b32
4 changed files with 59 additions and 24 deletions

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 15:52:44 by qmennen #+# #+# */
/* Updated: 2025/05/28 17:14:28 by qmennen ### ########.fr */
/* :::::::: */
/* types.h :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/15 15:52:44 by qmennen #+# #+# */
/* Updated: 2025/05/29 09:35:12 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -118,6 +118,7 @@ typedef struct s_screen
mlx_image_t *hud;
unsigned int width;
unsigned int height;
int flash;
} t_screen;
typedef enum e_side

View File

@ -3,10 +3,10 @@
/* :::::::: */
/* moves.c :+: :+: */
/* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/05/14 20:08:27 by whaffman #+# #+# */
/* Updated: 2025/05/23 15:11:58 by whaffman ######## odam.nl */
/* Updated: 2025/05/29 09:39:04 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -76,6 +76,7 @@ void visit_area(t_game *game)
}
}
void player_update(t_game *game, double delta_time)
{
game->player->is_moving = 0;
@ -92,4 +93,6 @@ void player_update(t_game *game, double delta_time)
rotate(game->player, -2.5, delta_time);
else if (get_key(game, MLX_KEY_RIGHT))
rotate(game->player, 2.5, delta_time);
}
if (get_key(game, MLX_KEY_SPACE))
game->screen->flash = 3;
}

View File

@ -1,16 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* render.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 16:28:10 by qmennen #+# #+# */
/* Updated: 2025/05/22 13:59:32 by qmennen ### ########.fr */
/* :::::::: */
/* render.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/15 16:28:10 by qmennen #+# #+# */
/* Updated: 2025/05/29 09:37:49 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void flash(t_game *game)
{
mlx_image_t *img;
int x;
int y;
if (game->screen->flash == 0)
return;
img = game->screen->img;
game->screen->flash--;
x=0;
while (x < img->width)
{
y = 0;
while (y < img->height)
{
mlx_put_pixel(img, x, y, 0xffffffff);
y++;
}
x++;
}
}
void cast_rays(t_game *game)
{
@ -26,4 +49,5 @@ void cast_rays(t_game *game)
x++;
}
render_sprites(render, game);
flash(game);
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* render_sprite.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/08 12:23:17 by qmennen #+# #+# */
/* Updated: 2025/05/28 17:13:59 by qmennen ### ########.fr */
/* :::::::: */
/* render_sprite.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/05/08 12:23:17 by qmennen #+# #+# */
/* Updated: 2025/05/29 09:47:41 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -67,6 +67,12 @@ static void draw_sprite_column(
}
}
void handle_flash(t_sprite *sprite, t_game *game)
{
if (sprite->type == SPRITE_TYPE_ENEMY && game->screen->flash > 0)
sprite->type = SPRITE_TYPE_COLLECTED;
}
void draw_sprite(t_game *game, t_sprite *sprite, t_render *render)
{
t_vec2_int start;
@ -82,6 +88,7 @@ void draw_sprite(t_game *game, t_sprite *sprite, t_render *render)
{
if (sprite_visible(game, sprite, render, x))
{
handle_flash(sprite, game);
column.start = start;
column.end = end;
column.x = x;