Update launch configuration, enhance shader functionality, and modify game mechanics

This commit is contained in:
Quinten Mennen 2025-06-11 17:46:33 +02:00
parent c784b5e5f7
commit 939866b7ce
17 changed files with 186 additions and 76 deletions

2
.vscode/launch.json vendored
View File

@ -6,7 +6,7 @@
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/build/debug/cub3D", // Replace with your executable path "program": "${workspaceFolder}/build/debug/cub3D", // Replace with your executable path
"args": ["test.cub"], "args": ["maps/invalid/test.cub"],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"environment": [], "environment": [],

View File

@ -1,17 +1,19 @@
# **************************************************************************** # # **************************************************************************** #
# # # #
# :::::::: # # ::: :::::::: #
# Makefile :+: :+: # # Makefile :+: :+: :+: #
# +:+ # # +:+ +:+ +:+ #
# By: whaffman <whaffman@student.codam.nl> +#+ # # By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ #
# +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/10/15 11:48:46 by whaffman #+# #+# # # Created: 2024/10/15 11:48:46 by whaffman #+# #+# #
# Updated: 2025/06/10 16:22:24 by whaffman ######## odam.nl # # Updated: 2025/06/11 17:41:17 by qmennen ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
NAME = cub3D NAME = cub3D
FLAGS="-DFULLSCREEN=1"
DIST_PATH = dist DIST_PATH = dist
SRC_PATH = src SRC_PATH = src
INC_PATH = inc INC_PATH = inc
@ -46,10 +48,10 @@ SOURCES = $(shell basename -a $(shell find $(SRC_PATH) -type f -name "*.c"))
# Build configurations # Build configurations
BUILD_CONFIGS = release debug asan tsan BUILD_CONFIGS = release debug asan tsan
release_CFLAGS = -Wall -Wextra -Werror -flto -Ofast -march=native -mtune=native -ffast-math -DFULLSCREEN=0 release_CFLAGS = -Wall -Wextra -Werror -flto -Ofast -march=native -mtune=native -ffast-math
unity_CFLAGS = -Wall -Wextra -Werror -Ofast -march=native -mtune=native -ffast-math unity_CFLAGS = -Wall -Wextra -Werror -Ofast -march=native -mtune=native -ffast-math
debug_CFLAGS = -Wall -Wextra -Werror -g3 -DDEBUG -DDBG='fprintf(stderr, RED "DEBUG: " RESET "%s:%d (%s)\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);' debug_CFLAGS = -Wall -Wextra -Werror -g3 -DDEBUG -DDBG='fprintf(stderr, RED "DEBUG: " RESET "%s:%d (%s)\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);'
asan_CFLAGS = -Wall -Wextra -Werror -flto -fsanitize=address,leak,undefined -g3 -DFULLSCREEN=0 asan_CFLAGS = -Wall -Wextra -Werror -flto -fsanitize=address,leak,undefined -g3
tsan_CFLAGS = -Wall -Wextra -Werror -fsanitize=thread -g3 tsan_CFLAGS = -Wall -Wextra -Werror -fsanitize=thread -g3
RUN_ARGS=test.cub RUN_ARGS=test.cub

View File

@ -2,6 +2,7 @@
in vec2 TexCoord; in vec2 TexCoord;
flat in int TexIndex; flat in int TexIndex;
flat in vec3 originalTexCoord;
out vec4 FragColor; out vec4 FragColor;
uniform sampler2D Texture0; uniform sampler2D Texture0;
@ -37,10 +38,56 @@ float hash(vec2 p) {
return fract(p.x * p.y); return fract(p.x * p.y);
} }
vec2 fisheyeDistort(vec2 coord, float strength) {
// Scale down input coordinates to leave room for distortion
vec2 safeCoord = mix(vec2(0.5), coord, 0.85); // Scale down by 15%
vec2 centered = safeCoord * 2.0 - 1.0;
float distance = length(centered);
// Reduce strength near edges
float adjustedStrength = strength * (1.0 - smoothstep(0.7, 0.9, distance));
float distorted = distance * (1.0 + adjustedStrength * distance * distance);
vec2 distortedCoord;
if (distance < 0.001) {
distortedCoord = centered;
} else {
distortedCoord = centered * (distorted / distance);
}
distortedCoord = distortedCoord * 0.5 + 0.5;
return distortedCoord;
}
float calculateMask(vec2 coord, float fisheyeStrength, float maskThreshold, float softness) {
vec2 centered = coord * 2.0 - 1.0;
float distance = length(centered);
if (distance == 0.0) {
return 1.0;
}
float distorted = distance * (1.0 + fisheyeStrength * distance * distance);
vec2 distortedCoord = centered * (distorted / distance);
distortedCoord = distortedCoord * 0.5 + 0.5;
float maxDistortion = max(
max(abs(distortedCoord.x - 0.5), abs(distortedCoord.y - 0.5)) - 0.5,
0.0
);
float mask = 1.0 - smoothstep(maskThreshold - softness, maskThreshold + softness, maxDistortion);
return mask;
}
void main() void main()
{ {
vec4 texColor; vec4 texColor;
vec4 noiseColor; vec4 noiseColor;
vec2 distortedCoord;
switch (TexIndex) { switch (TexIndex) {
case 0: texColor = texture(Texture0, TexCoord); break; case 0: texColor = texture(Texture0, TexCoord); break;
@ -81,15 +128,16 @@ void main()
noise2 *= 0.9 + 0.1 * sin(uv.y * 400.0); noise2 *= 0.9 + 0.1 * sin(uv.y * 400.0);
noise3 *= 0.9 + 0.1 * sin(uv.y * 400.0); noise3 *= 0.9 + 0.1 * sin(uv.y * 400.0);
distortedCoord = fisheyeDistort(TexCoord, u_battery * 1.2);
float offset = 0.001 / (u_battery * u_battery + 0.001 ); float offset = 0.001 / (u_battery * u_battery + 0.001 );
offset = offset > .05 ? .05 : offset; offset = offset > .05 ? .05 : offset;
float r = texture(Texture1, TexCoord + vec2(offset * 5, 0.0)).r; float r = texture(Texture1, distortedCoord + vec2(offset * 5, 0.0)).r;
float g = texture(Texture1, TexCoord + vec2(0.0, offset * 2.0)).g; float g = texture(Texture1, distortedCoord + vec2(0.0, offset * 2.0)).g;
float b = texture(Texture1, TexCoord - vec2(offset, 0.0)).b; float b = texture(Texture1, distortedCoord - vec2(offset, 0.0)).b;
vec3 color = vec3(r, g, b); vec3 color = vec3(r, g, b);
vec3 noisyColor = mix(color.rgb, vec3(noise, noise2, noise3), (strength / 2 + .2)); vec3 noisyColor = mix(color.rgb, vec3(noise, noise2, noise3), (strength / 2 + .2));
// float flicker = 0.75 + sin(u_time * 6.0 + sin(u_time * 3)) * 0.25;
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;
@ -102,7 +150,10 @@ void main()
float inv_hit = 1.0 - u_hit_timer; float inv_hit = 1.0 - u_hit_timer;
noiseColor *= vec4(vig) * vec4(1.0, inv_hit, inv_hit, 1.0); noiseColor *= vec4(vig) * vec4(1.0, inv_hit, inv_hit, 1.0);
} }
FragColor = noiseColor;
float mask = calculateMask(gl_FragCoord.xy / u_resolution, 1, 0.08f, 0.02f);
FragColor = vec4(noiseColor.rgb * mask, noiseColor.a);
// FragColor = noiseColor;
} else { } else {
FragColor = texColor; FragColor = texColor;
} }

View File

@ -4,13 +4,44 @@ layout(location = 1) in vec2 aTexCoord;
layout(location = 2) in int aTexIndex; layout(location = 2) in int aTexIndex;
out vec2 TexCoord; out vec2 TexCoord;
flat out int TexIndex; flat out int TexIndex;
flat out vec3 originalTexCoord;
uniform mat4 ProjMatrix; uniform mat4 ProjMatrix;
uniform float u_bobtime;
uniform int u_ismoving;
const float bobbingSpeed = 18.0; // Speed of the bobbing effect
const float bobbingIntensity = 0.6; // Intensity of the bobbing effect
void main() void main()
{ {
// Add view bobbing vec3 position = aPos;
gl_Position = ProjMatrix * vec4(aPos, 1.0); originalTexCoord = aPos;
if (u_ismoving == 1 && aTexIndex == 1) {
// Calculate bobbing offset based on sine waves
float verticalBob = sin(u_bobtime * bobbingSpeed) * bobbingIntensity;
float horizontalBob = sin(u_bobtime * bobbingSpeed * 0.5) * bobbingIntensity * 0.3;
// Apply the bobbing offset
position.y += verticalBob;
position.x += horizontalBob;
// Optional: Add slight rotation for more realistic head movement
float tiltAngle = sin(u_bobtime * bobbingSpeed * 0.7) * bobbingIntensity * 0.02;
// Apply rotation around Z-axis (head tilt)
float cosA = cos(tiltAngle);
float sinA = sin(tiltAngle);
float newX = position.x * cosA - position.y * sinA;
float newY = position.x * sinA + position.y * cosA;
position.x = newX;
position.y = newY;
}
gl_Position = ProjMatrix * vec4(position, 1.0);
TexCoord = aTexCoord; TexCoord = aTexCoord;
TexIndex = aTexIndex; TexIndex = aTexIndex;
} }

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* ::: :::::::: */
/* cub3d.h :+: :+: */ /* cub3d.h :+: :+: :+: */
/* +:+ */ /* +:+ +:+ +:+ */
/* 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/06/10 20:44:48 by whaffman ######## odam.nl */ /* Updated: 2025/06/11 16:29:00 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,10 +20,11 @@
# define HEIGHT 1080 # define HEIGHT 1080
# define TITLE "Cub3D" # define TITLE "Cub3D"
# define ATTACK_DAMAGE 0.05f # define ATTACK_DAMAGE 0.03f
# define INITIAL_BATTERY 0.5f # define INITIAL_BATTERY 1.0f
# define BATTERY_RATE 0.01f # define BATTERY_RATE 0.01f
# define FLASH_BATTERY 0.05f # define FLASH_BATTERY 0.05f
# define SLIDESHOW_DURATION 3.0f
# ifndef FULLSCREEN # ifndef FULLSCREEN
# define FULLSCREEN 1 # define FULLSCREEN 1
@ -47,7 +48,7 @@
# define CYAN "\033[0;36m" # define CYAN "\033[0;36m"
# define WHITE "\033[0;37m" # define WHITE "\033[0;37m"
# define MAX_SCREENSHOTS 3 # define MAX_SCREENSHOTS 10
# define NUM_KEYS 300 # define NUM_KEYS 300
# define TILE_SIZE 8 # define TILE_SIZE 8
# define MINIMAP_SIZE 300 # define MINIMAP_SIZE 300

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* ::: :::::::: */
/* types.h :+: :+: */ /* types.h :+: :+: :+: */
/* +:+ */ /* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 15:52:44 by qmennen #+# #+# */ /* Created: 2025/04/15 15:52:44 by qmennen #+# #+# */
/* Updated: 2025/06/10 19:30:40 by whaffman ######## odam.nl */ /* Updated: 2025/06/11 16:56:03 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -127,6 +127,8 @@ typedef struct s_screen
int u_resolution_location; int u_resolution_location;
int u_hit_timer_location; int u_hit_timer_location;
int u_enabled_location; int u_enabled_location;
int u_bobtime_location;
int u_ismoving_location;
int flash; int flash;
} t_screen; } t_screen;

View File

@ -6,7 +6,8 @@ EA ./assets/bricksx64.png
F 90,30,30 F 90,30,30
C 100,100,200 C 100,100,200
1111111 1111111
100W001 1000001
1N00001 1W00001
1111111 1111111

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 15:46:08 by qmennen #+# #+# */ /* Created: 2025/04/15 15:46:08 by qmennen #+# #+# */
/* Updated: 2025/06/11 14:49:08 by qmennen ### ########.fr */ /* Updated: 2025/06/11 17:44:59 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -52,11 +52,6 @@ void game_run(t_game *game)
cast_rays(game); cast_rays(game);
update_monsters(game); update_monsters(game);
render_map(game); render_map(game);
if (game->player->is_moving)
{
game->screen->img->instances[0].x = sin(mlx_get_time() * 10) * 20;
game->screen->img->instances[0].y = cos(mlx_get_time() * 18) * 10;
}
handle_battery(game); handle_battery(game);
handle_record(game); handle_record(game);
handle_mouse(game); handle_mouse(game);

View File

@ -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/05 18:44:18 by qmennen ### ########.fr */ /* Updated: 2025/06/11 16:26:14 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -23,7 +23,7 @@ int player_create(t_game **game)
player->pos.x = -1; player->pos.x = -1;
player->pos.y = -1; player->pos.y = -1;
player->speed = 3.f; player->speed = 3.f;
player->battery = .5f; player->battery = INITIAL_BATTERY;
player->hit_timer = 0.f; player->hit_timer = 0.f;
(*game)->player = player; (*game)->player = player;
return (SUCCESS); return (SUCCESS);

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* ::: :::::::: */
/* get_fraction.c :+: :+: */ /* get_fraction.c :+: :+: :+: */
/* +:+ */ /* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/12 12:09:27 by whaffman #+# #+# */ /* Created: 2025/05/12 12:09:27 by whaffman #+# #+# */
/* Updated: 2025/05/14 16:13:38 by whaffman ######## odam.nl */ /* Updated: 2025/06/11 15:19:32 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* ::: :::::::: */
/* end_screen.c :+: :+: */ /* end_screen.c :+: :+: :+: */
/* +:+ */ /* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/03 16:20:35 by qmennen #+# #+# */ /* Created: 2025/06/03 16:20:35 by qmennen #+# #+# */
/* Updated: 2025/06/10 21:39:35 by whaffman ######## odam.nl */ /* Updated: 2025/06/11 17:44:51 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,7 +21,8 @@ static void slideshow(t_game *game)
game->screenshots[frame_idx]->instances[0].enabled = true; game->screenshots[frame_idx]->instances[0].enabled = true;
if (last_frame_time == 0) if (last_frame_time == 0)
last_frame_time = mlx_get_time(); last_frame_time = mlx_get_time();
if (mlx_get_time() - last_frame_time > 5 && frame_idx < game->screenshot_idx if (mlx_get_time() - last_frame_time > SLIDESHOW_DURATION
&& frame_idx < game->screenshot_idx
&& frame_idx < MAX_SCREENSHOTS) && frame_idx < MAX_SCREENSHOTS)
{ {
game->screenshots[frame_idx++]->instances[0].enabled = true; game->screenshots[frame_idx++]->instances[0].enabled = true;

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/10 14:54:49 by qmennen #+# #+# */ /* Created: 2025/06/10 14:54:49 by qmennen #+# #+# */
/* Updated: 2025/06/10 15:30:18 by qmennen ### ########.fr */ /* Updated: 2025/06/11 16:24:05 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -53,7 +53,6 @@ void draw_score_line(
free(text); free(text);
return ; return ;
} }
printf("Drawing score line: %s at (%d, %d)\n", text, pos.x, pos.y);
*img = mlx_put_string(mlx, text, pos.x, pos.y); *img = mlx_put_string(mlx, text, pos.x, pos.y);
free(text); free(text);
} }

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/28 17:15:52 by qmennen #+# #+# */ /* Created: 2025/05/28 17:15:52 by qmennen #+# #+# */
/* Updated: 2025/06/10 14:45:44 by qmennen ### ########.fr */ /* Updated: 2025/06/11 16:22:09 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -28,7 +28,7 @@ void update_monsters(t_game *game)
continue ; continue ;
d = sub(game->player->pos, sprite->pos); d = sub(game->player->pos, sprite->pos);
dist_squared = d.x * d.x + d.y * d.y; dist_squared = d.x * d.x + d.y * d.y;
if (dist_squared >= 0.02) if (dist_squared >= 0.02 && dist_squared < 50)
{ {
inv_dist = 1.0 / sqrt(dist_squared); inv_dist = 1.0 / sqrt(dist_squared);
sprite->pos.x += d.x * inv_dist * .05f; sprite->pos.x += d.x * inv_dist * .05f;

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/14 13:06:39 by whaffman #+# #+# */ /* Created: 2025/05/14 13:06:39 by whaffman #+# #+# */
/* Updated: 2025/06/10 15:41:41 by qmennen ### ########.fr */ /* Updated: 2025/06/11 17:45:31 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -23,27 +23,46 @@ static t_vec2 calc_floor_step(t_game *game,
return (floor_step); return (floor_step);
} }
static void draw_floor_ceiling_pixel(t_game *game, static void draw_floor_pixel(t_game *game,
t_vec2_int coord, double row_dist, t_vec2 floor_pos) t_vec2_int coord, double row_dist, t_vec2 floor_pos)
{ {
const t_vec2_int tex = vec2_to_int( t_vec2_int tex;
mul(get_fraction(floor_pos), game->map->texture_floor->width)); int color;
int color; int tex_width;
if (game->map->texture_floor == NULL) if (game->map->texture_floor == NULL)
color = game->map->floor_color << 8 | (int)(1.0 / row_dist * 255); color = game->map->floor_color << 8 | (int)(1.0 / row_dist * 255);
else else
{
tex_width = game->map->texture_floor->width;
tex = vec2_to_int(
mul(get_fraction(floor_pos), tex_width));
color = get_texture_color(game->map->texture_floor, color = get_texture_color(game->map->texture_floor,
(t_render){.perp_dist = row_dist, .sign = 0, .door = 0, (t_render){.perp_dist = row_dist, .sign = 0, .door = 0,
.side = SIDE_DOOR, .wall_x = 0}, tex); .side = SIDE_DOOR, .wall_x = 0}, tex);
}
mlx_put_pixel(game->screen->img, mlx_put_pixel(game->screen->img,
coord.x, coord.y, color); coord.x, coord.y, color);
}
static void draw_ceiling_pixel(t_game *game,
t_vec2_int coord, double row_dist, t_vec2 ceiling_pos)
{
t_vec2_int tex;
int color;
int tex_width;
if (game->map->texture_ceiling == NULL) if (game->map->texture_ceiling == NULL)
color = game->map->ceiling_color << 8 | (int)(1.0 / row_dist * 255); color = game->map->ceiling_color << 8 | (int)(1.0 / row_dist * 255);
else else
{
tex_width = game->map->texture_ceiling->width;
tex = vec2_to_int(
mul(get_fraction(ceiling_pos), tex_width));
color = get_texture_color(game->map->texture_ceiling, color = get_texture_color(game->map->texture_ceiling,
(t_render){.perp_dist = row_dist, .sign = 0, .door = 0, (t_render){.perp_dist = row_dist, .sign = 0, .door = 0,
.side = SIDE_DOOR, .wall_x = 0}, tex); .side = SIDE_DOOR, .wall_x = 0}, tex);
}
mlx_put_pixel(game->screen->img, mlx_put_pixel(game->screen->img,
coord.x, game->screen->height - coord.y - 1, color); coord.x, game->screen->height - coord.y - 1, color);
} }
@ -63,7 +82,8 @@ static void draw_floor_row(t_game *game,
return ; return ;
while (coord.x < (int) game->screen->width) while (coord.x < (int) game->screen->width)
{ {
draw_floor_ceiling_pixel(game, coord, row_dist, floor_pos); draw_floor_pixel(game, coord, row_dist, floor_pos);
draw_ceiling_pixel(game, coord, row_dist, floor_pos);
floor_pos = add(floor_pos, floor_step); floor_pos = add(floor_pos, floor_step);
coord.x++; coord.x++;
} }

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/08 18:27:59 by qmennen #+# #+# */ /* Created: 2025/05/08 18:27:59 by qmennen #+# #+# */
/* Updated: 2025/06/10 15:48:16 by qmennen ### ########.fr */ /* Updated: 2025/06/11 17:45:39 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,6 +17,9 @@
void set_uniforms(t_game *game) void set_uniforms(t_game *game)
{ {
glUniform1f(game->screen->u_time_location, (float)mlx_get_time()); glUniform1f(game->screen->u_time_location, (float)mlx_get_time());
glUniform1f(game->screen->u_bobtime_location, (float)mlx_get_time());
glUniform1i(game->screen->u_ismoving_location,
game->player->is_moving);
glUniform1f(game->screen->u_battery_location, game->player->battery); glUniform1f(game->screen->u_battery_location, game->player->battery);
glUniform2f(game->screen->u_resolution_location, glUniform2f(game->screen->u_resolution_location,
(float)game->screen->width, (float)game->screen->height); (float)game->screen->width, (float)game->screen->height);
@ -40,6 +43,10 @@ int load_uniforms(t_game **game)
ctx->shaderprogram, "u_enabled"); ctx->shaderprogram, "u_enabled");
(*game)->screen->u_resolution_location = glGetUniformLocation( (*game)->screen->u_resolution_location = glGetUniformLocation(
ctx->shaderprogram, "u_resolution"); ctx->shaderprogram, "u_resolution");
(*game)->screen->u_bobtime_location = glGetUniformLocation(
ctx->shaderprogram, "u_bobtime");
(*game)->screen->u_ismoving_location = glGetUniformLocation(
ctx->shaderprogram, "u_ismoving");
if ((*game)->screen->u_time_location < 0 if ((*game)->screen->u_time_location < 0
|| (*game)->screen->u_battery_location < 0 || (*game)->screen->u_battery_location < 0
|| (*game)->screen->u_hit_timer_location < 0 || (*game)->screen->u_hit_timer_location < 0

View File

@ -24,20 +24,20 @@ CT ./assets/ceiling64x64.png
-e e ./assets/flying_eye.png -e e ./assets/flying_eye.png
1111111 111 1111 111111 1111111111 111111 1111111 111 1111 111111 1111111111 111111
1000001110111001 100001 1000000001 10001 1000001110111001 100001 1000000001 10e01
10010000000b0e01 100001 100000110111100011 10010000000b0e01 100001 100000110111100011
10b0001110000001110011111111 1100b0001000000001 10b0001110000001110011111111 1100b0001000000001
1000001 1000100a000010000001 100000e0100b000001 1000001 1000100a000010000001 100000e0100b000001
100m00111000100000b00000b00111110p00000100p00m001 100m00111000100000b00000b00111110p00000100p00m001
10b0e0bb00001111111111100000000000111111000000001 10b0e0bb0000111111111110000000000011111100e000001
1000t0bW00001 1000011111111 1000001001 1000t0bW00001 1000011111111 1000001001
10p0011111DD1 111111100001 1111111111110001 10p0011111DD1 111111100001 1111111111110001
100001 1001 1p00000000011111111000010111 10b01 100001 1001 1p00000000011111111000010111 10b01
111111 1001 10000010000000000010b0000101 100001 111111 10e1 100e0010000000000010b000e101 100001
1b01 10000p1111111111111000010001 10b00m1 1b01 10000p1111111111111000010001 10b00m1
1001 100000000000000000000111b001 100001 1001 100000000000000000000111b0e1 10e001
1001 1b000000b0000p00000011 11111 100001 1001 1b000000b0000p00000011 11111 100001
10011111111100111111111111111111001110001 10011111111100111111111111111111001110001
1000000000000000000000b000000000000000001 1000000000e00000000000b000000000000000001
111111b0111111101100111100011101011111111 111111b0111111101100111100011101011111111
1111 1111111 11111 11111 1111 1111111 11111 11111

View File

@ -19,7 +19,7 @@ for file in "$INVALID_DIR"/*; do
test_name=$(basename "$file" | sed -e 's/\..*$//') test_name=$(basename "$file" | sed -e 's/\..*$//')
# echo -e "${bu}Testing $test_name...${reset}" # echo -e "${bu}Testing $test_name...${reset}"
# Run the file with ./cub3D and send SIGINT after 1 second # Run the file with ./cub3D and send SIGINT after 1 second
timeout 1 ./cub3D "$file" > /dev/null 2>&1 timeout 1 ./cub3D "$file" > /dev/null
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
# Print OK! [filename] if exit status is 1 # Print OK! [filename] if exit status is 1
echo -e "${gb}OK!${reset} $test_name" echo -e "${gb}OK!${reset} $test_name"