reorganization and red flash
This commit is contained in:
parent
c05d73f3a5
commit
df57505ad3
@ -39,6 +39,8 @@ float hash(vec2 p) {
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 texColor;
|
vec4 texColor;
|
||||||
|
vec4 noiseColor;
|
||||||
|
|
||||||
switch (TexIndex) {
|
switch (TexIndex) {
|
||||||
case 0: texColor = texture(Texture0, TexCoord); break;
|
case 0: texColor = texture(Texture0, TexCoord); break;
|
||||||
case 1: texColor = texture(Texture1, TexCoord); break;
|
case 1: texColor = texture(Texture1, TexCoord); break;
|
||||||
@ -58,12 +60,6 @@ void main()
|
|||||||
case 15: texColor = texture(Texture15, TexCoord); break;
|
case 15: texColor = texture(Texture15, TexCoord); break;
|
||||||
default: texColor = vec4(1.0, 0.0, 0.0, 1.0); break;
|
default: texColor = vec4(1.0, 0.0, 0.0, 1.0); break;
|
||||||
}
|
}
|
||||||
//generate a red flash
|
|
||||||
// if (u_hit_timer > 0.0) {
|
|
||||||
// float flash = sin(u_hit_timer * 10.0) * 0.5 + 0.5;
|
|
||||||
// FragColor = vec4(1.0, flash * 0.2, flash * 0.2, texColor.a);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
if (TexIndex == 1) {
|
if (TexIndex == 1) {
|
||||||
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
||||||
uv.x *= u_resolution.x / u_resolution.y;
|
uv.x *= u_resolution.x / u_resolution.y;
|
||||||
@ -92,8 +88,16 @@ void main()
|
|||||||
float flicker = (1 - strength * 0.5) + 0.25 * (strength * sin(u_time + sin(u_time * 7.0) + 1));
|
float flicker = (1 - strength * 0.5) + 0.25 * (strength * sin(u_time + sin(u_time * 7.0) + 1));
|
||||||
|
|
||||||
float dim = u_battery < 0.1 ? u_battery * 10.0 : 1;
|
float dim = u_battery < 0.1 ? u_battery * 10.0 : 1;
|
||||||
FragColor = vec4(noisyColor, texColor.a * flicker * dim);
|
noiseColor = vec4(noisyColor, texColor.a * flicker * dim);
|
||||||
|
if (u_hit_timer > 0.0) {
|
||||||
|
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
||||||
|
uv *= 1.0 - uv.yx;
|
||||||
|
float vig = uv.x*uv.y * 15.0;
|
||||||
|
vig = pow(vig, 0.25);
|
||||||
|
float inv_hit = 1.0 - u_hit_timer;
|
||||||
|
noiseColor *= vec4(vig) * vec4(1.0, inv_hit, inv_hit, 1.0);
|
||||||
|
}
|
||||||
|
FragColor = noiseColor;
|
||||||
} else {
|
} else {
|
||||||
FragColor = texColor;
|
FragColor = texColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/15 12:22:29 by qmennen #+# #+# */
|
/* Created: 2025/04/15 12:22:29 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/28 17:30:51 by qmennen ### ########.fr */
|
/* Updated: 2025/06/03 15:50:37 by qmennen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -48,7 +48,6 @@
|
|||||||
# include "types.h"
|
# include "types.h"
|
||||||
# include "errors.h"
|
# include "errors.h"
|
||||||
# include "vec_math.h"
|
# include "vec_math.h"
|
||||||
# include "map.h"
|
|
||||||
# include "game.h"
|
# include "game.h"
|
||||||
# include "screen.h"
|
# include "screen.h"
|
||||||
# include "keyboard.h"
|
# include "keyboard.h"
|
||||||
|
|||||||
31
inc/map.h
31
inc/map.h
@ -1,31 +0,0 @@
|
|||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* map.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2025/04/17 19:19:19 by qmennen #+# #+# */
|
|
||||||
/* Updated: 2025/05/28 17:07:28 by qmennen ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef MAP_H
|
|
||||||
# define MAP_H
|
|
||||||
|
|
||||||
# include "cub3d.h"
|
|
||||||
|
|
||||||
int map_create(t_game **game, const char *mapfile);
|
|
||||||
void map_free(t_map *map);
|
|
||||||
void print_map(t_map *map);
|
|
||||||
t_tile get_tile(t_map *map, int x, int y);
|
|
||||||
int enclosed_map(t_map *map);
|
|
||||||
void grid_free(t_tile **grid, int height);
|
|
||||||
t_tile **copy_map(t_tile **grid, int width, int height);
|
|
||||||
int parse_args(const char *mapfile, t_game *game);
|
|
||||||
t_tile **create_grid(int width, int height);
|
|
||||||
int find_player_or_empty(t_map *map, int *x, int *y);
|
|
||||||
int floodfill(t_map *map, int x, int y);
|
|
||||||
t_sprite make_sprite(t_sprite_lib *def, double x, double y);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
26
inc/parser.h
26
inc/parser.h
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* :::::::: */
|
/* ::: :::::::: */
|
||||||
/* parser.h :+: :+: */
|
/* parser.h :+: :+: :+: */
|
||||||
/* +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
||||||
/* +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/19 14:41:55 by whaffman #+# #+# */
|
/* Created: 2025/04/19 14:41:55 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/06/03 14:43:25 by whaffman ######## odam.nl */
|
/* Updated: 2025/06/03 15:49:59 by qmennen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -36,5 +36,17 @@ int handle_fc_color(char *token, t_map *map);
|
|||||||
int handle_fc_texture(char *token, t_map *map);
|
int handle_fc_texture(char *token, t_map *map);
|
||||||
int handle_sprite(char *token, t_map *map);
|
int handle_sprite(char *token, t_map *map);
|
||||||
mlx_texture_t *load_texture(const char *path);
|
mlx_texture_t *load_texture(const char *path);
|
||||||
|
int map_create(t_game **game, const char *mapfile);
|
||||||
|
void map_free(t_map *map);
|
||||||
|
void print_map(t_map *map);
|
||||||
|
t_tile get_tile(t_map *map, int x, int y);
|
||||||
|
int enclosed_map(t_map *map);
|
||||||
|
void grid_free(t_tile **grid, int height);
|
||||||
|
t_tile **copy_map(t_tile **grid, int width, int height);
|
||||||
|
int parse_args(const char *mapfile, t_game *game);
|
||||||
|
t_tile **create_grid(int width, int height);
|
||||||
|
int find_player_or_empty(t_map *map, int *x, int *y);
|
||||||
|
int floodfill(t_map *map, int x, int y);
|
||||||
|
t_sprite make_sprite(t_sprite_lib *def, double x, double y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -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/06/03 13:42:51 by whaffman ######## odam.nl */
|
/* Updated: 2025/06/03 15:18:54 by qmennen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -34,7 +34,10 @@ int collision_sprite(t_map *map, t_player *player, double xa, double ya)
|
|||||||
&& fabs(player->pos.y + ya - sprites[i].pos.y) < 0.5))
|
&& fabs(player->pos.y + ya - sprites[i].pos.y) < 0.5))
|
||||||
{
|
{
|
||||||
if (sprites[i].type == SPRITE_TYPE_ENEMY)
|
if (sprites[i].type == SPRITE_TYPE_ENEMY)
|
||||||
|
{
|
||||||
player->battery -= 0.0001;
|
player->battery -= 0.0001;
|
||||||
|
player->hit_timer = .65f;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprites[i].type = SPRITE_TYPE_COLLECTED;
|
sprites[i].type = SPRITE_TYPE_COLLECTED;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/14 20:08:27 by whaffman #+# #+# */
|
/* Created: 2025/05/14 20:08:27 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/06/03 14:54:45 by qmennen ### ########.fr */
|
/* Updated: 2025/06/03 15:10:49 by qmennen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -97,7 +97,5 @@ void player_update(t_game *game, double delta_time)
|
|||||||
game->player->battery -= 0.1f;
|
game->player->battery -= 0.1f;
|
||||||
}
|
}
|
||||||
if (game->player->hit_timer > 0)
|
if (game->player->hit_timer > 0)
|
||||||
{
|
game->player->hit_timer -= .1f;
|
||||||
game->player->hit_timer -= 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/15 18:53:19 by qmennen #+# #+# */
|
/* Created: 2025/04/15 18:53:19 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/06/03 14:55:17 by qmennen ### ########.fr */
|
/* Updated: 2025/06/03 15:18:22 by qmennen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ int player_create(t_game **game)
|
|||||||
player->pos.y = -1;
|
player->pos.y = -1;
|
||||||
player->speed = 3.f;
|
player->speed = 3.f;
|
||||||
player->battery = .5f;
|
player->battery = .5f;
|
||||||
player->hit_timer = 10.0f;
|
player->hit_timer = 0.f;
|
||||||
(*game)->player = player;
|
(*game)->player = player;
|
||||||
return (SUCCESS);
|
return (SUCCESS);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* :::::::: */
|
/* ::: :::::::: */
|
||||||
/* render_sprite.c :+: :+: */
|
/* render_sprite.c :+: :+: :+: */
|
||||||
/* +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
||||||
/* +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/08 12:23:17 by qmennen #+# #+# */
|
/* Created: 2025/05/08 12:23:17 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/06/03 14:47:08 by whaffman ######## odam.nl */
|
/* Updated: 2025/06/03 15:00:43 by qmennen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/15 15:30:27 by qmennen #+# #+# */
|
/* Created: 2025/04/15 15:30:27 by qmennen #+# #+# */
|
||||||
/* Updated: 2025/05/28 14:24:41 by qmennen ### ########.fr */
|
/* Updated: 2025/06/03 15:47:36 by qmennen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ int screen_create(t_game **game)
|
|||||||
ft_memset(screen, 0, sizeof(t_screen));
|
ft_memset(screen, 0, sizeof(t_screen));
|
||||||
screen->width = WIDTH;
|
screen->width = WIDTH;
|
||||||
screen->height = HEIGHT;
|
screen->height = HEIGHT;
|
||||||
mlx_set_setting(MLX_STRETCH_IMAGE, 1);
|
mlx_set_setting(MLX_FULLSCREEN, 1);
|
||||||
mlx = mlx_init(WIDTH, HEIGHT, TITLE, true);
|
mlx = mlx_init(WIDTH, HEIGHT, TITLE, true);
|
||||||
if (!mlx)
|
if (!mlx)
|
||||||
return (FAILURE);
|
return (FAILURE);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user