all norm exept for render_sprites

This commit is contained in:
Willem Haffmans 2025-05-14 20:34:45 +02:00
parent 08edfa99a6
commit f9272b27c7
13 changed files with 182 additions and 157 deletions

View File

@ -3,10 +3,10 @@
/* :::::::: */ /* :::::::: */
/* player.h :+: :+: */ /* player.h :+: :+: */
/* +:+ */ /* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/15 18:53:27 by qmennen #+# #+# */ /* Created: 2025/04/15 18:53:27 by qmennen #+# #+# */
/* Updated: 2025/05/14 12:43:14 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:08:48 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,4 +19,5 @@ int player_create(t_game **game);
void player_render(t_screen *screen, t_player *player); void player_render(t_screen *screen, t_player *player);
void player_update(t_game *game, double delta_time); void player_update(t_game *game, double delta_time);
#endif #endif

View File

@ -3,10 +3,10 @@
/* :::::::: */ /* :::::::: */
/* game.c :+: :+: */ /* game.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/15 15:46:08 by qmennen #+# #+# */ /* Created: 2025/04/15 15:46:08 by qmennen #+# #+# */
/* Updated: 2025/05/09 14:51:14 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 19:59:05 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -58,12 +58,11 @@ void game_loop(void *param)
player_update(game, delta_time); player_update(game, delta_time);
cast_rays(game); cast_rays(game);
render_map(game); render_map(game);
//render_entities(game);
keyboard_update(game); keyboard_update(game);
if (game->player->is_moving) if (game->player->is_moving)
{ {
game->screen->img->instances[0].x = (int)(sin((double)framecount / 4.0) * 20); game->screen->img->instances[0].x = sin((double)framecount / 4.0) * 20;
game->screen->img->instances[0].y = (int)(( 0.5 * cos((double)framecount / 2.0)) * 20); game->screen->img->instances[0].y = cos((double)framecount / 2.0) * 10;
} }
} }

View File

@ -3,21 +3,17 @@
/* :::::::: */ /* :::::::: */
/* map_create.c :+: :+: */ /* map_create.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/23 12:21:13 by whaffman #+# #+# */ /* Created: 2025/04/23 12:21:13 by whaffman #+# #+# */
/* Updated: 2025/05/07 11:52:14 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:24:32 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "cub3d.h" #include "cub3d.h"
int map_create(t_game **game, const char *mapfile) static int map_allocate(t_game **game)
{ {
t_tile **grid;
if (!(*game))
return (FAILURE);
(*game)->map = malloc(sizeof(t_map)); (*game)->map = malloc(sizeof(t_map));
if (!(*game)->map) if (!(*game)->map)
{ {
@ -25,15 +21,30 @@ int map_create(t_game **game, const char *mapfile)
return (FAILURE); return (FAILURE);
} }
ft_memset((*game)->map->textures, 0, sizeof((*game)->map->textures)); ft_memset((*game)->map->textures, 0, sizeof((*game)->map->textures));
return (SUCCESS);
}
static int map_parse_and_copy(t_game **game,
const char *mapfile, t_tile ***out_grid)
{
t_tile **grid;
if (!parse_args(mapfile, (*game))) if (!parse_args(mapfile, (*game)))
return (FAILURE); return (FAILURE);
grid = copy_map((*game)->map->grid, (*game)->map->width, (*game)->map->height); grid = copy_map((*game)->map->grid,
(*game)->map->width, (*game)->map->height);
if (!grid) if (!grid)
{ {
perror("Error copying (*game)->map"); perror("Error copying (*game)->map");
free((*game)->map); free((*game)->map);
return (FAILURE); return (FAILURE);
} }
*out_grid = grid;
return (SUCCESS);
}
static int map_validate_and_finalize(t_game **game, t_tile **grid)
{
if (!enclosed_map((*game)->map)) if (!enclosed_map((*game)->map))
{ {
ft_putendl_fd("Map is not enclosed", STDERR_FILENO); ft_putendl_fd("Map is not enclosed", STDERR_FILENO);
@ -46,3 +57,16 @@ int map_create(t_game **game, const char *mapfile)
print_config((*game)->map); print_config((*game)->map);
return (SUCCESS); return (SUCCESS);
} }
int map_create(t_game **game, const char *mapfile)
{
t_tile **grid;
if (!(*game))
return (FAILURE);
if (map_allocate(game) == FAILURE)
return (FAILURE);
if (map_parse_and_copy(game, mapfile, &grid) == FAILURE)
return (FAILURE);
return (map_validate_and_finalize(game, grid));
}

View File

@ -6,14 +6,14 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/23 12:22:28 by whaffman #+# #+# */ /* Created: 2025/04/23 12:22:28 by whaffman #+# #+# */
/* Updated: 2025/05/14 12:48:03 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 19:57:03 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <stdlib.h> #include <stdlib.h>
#include "cub3d.h" #include "cub3d.h"
void map_free(t_map *map) void map_free(t_map *map)
{ {
grid_free(map->grid, map->height); grid_free(map->grid, map->height);
free(map->north_texture); free(map->north_texture);

74
src/moves.c Normal file
View File

@ -0,0 +1,74 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* moves.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/05/14 20:08:27 by whaffman #+# #+# */
/* Updated: 2025/05/14 20:14:24 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "cub3d.h"
static void move(t_map *map, t_player *player, int dir, double delta)
{
double xa;
double ya;
xa = dir * player->dir.x * player->speed * delta;
ya = dir * player->dir.y * player->speed * delta;
if (xa != 0 && collision_horizontal(map, player, xa))
{
player->pos.x += xa;
player->is_moving = 1;
}
if (ya != 0 && collision_vertical(map, player, ya))
{
player->pos.y += ya;
player->is_moving = 1;
}
}
static void strave(t_map *map, t_player *player, int dir, double delta)
{
double xa;
double ya;
xa = dir * perp(player->dir).x * player->speed * delta;
ya = dir * perp(player->dir).y * player->speed * delta;
if (xa != 0 && collision_horizontal(map, player, xa))
{
player->pos.x += xa;
player->is_moving = 1;
}
if (ya != 0 && collision_vertical(map, player, ya))
{
player->is_moving = 1;
player->pos.y += ya;
}
}
static void rotate(t_player *player, double rot_speed, double delta)
{
player->dir = rot(player->dir, rot_speed * delta);
player->camera = rot(player->camera, rot_speed * delta);
}
void player_update(t_game *game, double delta_time)
{
game->player->is_moving = 0;
if (get_key(game, MLX_KEY_W))
move(game->map, game->player, 1, delta_time);
else if (get_key(game, MLX_KEY_S))
move(game->map, game->player, -1, delta_time);
if (get_key(game, MLX_KEY_A))
strave(game->map, game->player, -1, delta_time);
else if (get_key(game, MLX_KEY_D))
strave(game->map, game->player, 1, delta_time);
if (get_key(game, MLX_KEY_LEFT))
rotate(game->player, -2.5, delta_time);
else if (get_key(game, MLX_KEY_RIGHT))
rotate(game->player, 2.5, delta_time);
}

View File

@ -6,15 +6,15 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/22 13:10:06 by whaffman #+# #+# */ /* Created: 2025/04/22 13:10:06 by whaffman #+# #+# */
/* Updated: 2025/05/14 12:48:03 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:13:13 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "cub3d.h" #include "cub3d.h"
int parse_config_line(const char *line, t_map *map) int parse_config_line(const char *line, t_map *map)
{ {
char **tokens; char **tokens;
tokens = ft_split(line, ' '); tokens = ft_split(line, ' ');
if (!tokens || !tokens[0] || !tokens[1] || tokens[2]) if (!tokens || !tokens[0] || !tokens[1] || tokens[2])

View File

@ -6,13 +6,13 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/22 13:11:18 by whaffman #+# #+# */ /* Created: 2025/04/22 13:11:18 by whaffman #+# #+# */
/* Updated: 2025/05/14 12:48:03 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:00:32 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "cub3d.h" #include "cub3d.h"
void print_config(t_map *map) void print_config(t_map *map)
{ {
printf("Map:\n"); printf("Map:\n");
printf("Width: %d, Height: %d\n", map->width, map->height); printf("Width: %d, Height: %d\n", map->width, map->height);

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/15 18:53:19 by qmennen #+# #+# */ /* Created: 2025/04/15 18:53:19 by qmennen #+# #+# */
/* Updated: 2025/05/14 18:31:54 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:14:10 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -32,67 +32,6 @@ int player_create(t_game **game)
return (SUCCESS); return (SUCCESS);
} }
static void move(t_map *map, t_player *player, int dir, double delta)
{
double xa;
double ya;
xa = dir * player->dir.x * player->speed * delta;
ya = dir * player->dir.y * player->speed * delta;
if (xa != 0 && collision_horizontal(map, player, xa))
{
player->pos.x += xa;
player->is_moving = 1;
}
if (ya != 0 && collision_vertical(map, player, ya))
{
player->pos.y += ya;
player->is_moving = 1;
}
}
static void strave(t_map *map, t_player *player, int dir, double delta)
{
double xa;
double ya;
xa = dir * perp(player->dir).x * player->speed * delta;
ya = dir * perp(player->dir).y * player->speed * delta;
if (xa != 0 && collision_horizontal(map, player, xa))
{
player->pos.x += xa;
player->is_moving = 1;
}
if (ya != 0 && collision_vertical(map, player, ya))
{
player->is_moving = 1;
player->pos.y += ya;
}
}
static void rotate(t_player *player, double rot_speed, double delta)
{
player->dir = rot(player->dir, rot_speed * delta);
player->camera = rot(player->camera, rot_speed * delta);
}
void player_update(t_game *game, double delta_time)
{
game->player->is_moving = 0;
if (get_key(game, MLX_KEY_W))
move(game->map, game->player, 1, delta_time);
else if (get_key(game, MLX_KEY_S))
move(game->map, game->player, -1, delta_time);
if (get_key(game, MLX_KEY_A))
strave(game->map, game->player, -1, delta_time);
else if (get_key(game, MLX_KEY_D))
strave(game->map, game->player, 1, delta_time);
if (get_key(game, MLX_KEY_LEFT))
rotate(game->player, -2.5, delta_time);
else if (get_key(game, MLX_KEY_RIGHT))
rotate(game->player, 2.5, delta_time);
}
void player_render(t_screen *screen, t_player *player) void player_render(t_screen *screen, t_player *player)
{ {
t_vec2 direction; t_vec2 direction;

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/05/08 12:23:17 by qmennen #+# #+# */ /* Created: 2025/05/08 12:23:17 by qmennen #+# #+# */
/* Updated: 2025/05/14 16:10:05 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:06:28 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -93,8 +93,8 @@ unsigned int sample_texture_color(
| (texture->pixels[index + 3] != 0) * alpha); | (texture->pixels[index + 3] != 0) * alpha);
} }
static void get_start_end(t_game *game, static void get_start_end(t_game *game,
t_sprite *sprite, t_vec2_int *start, t_vec2_int *end) t_sprite *sprite, t_vec2_int *start, t_vec2_int *end)
{ {
double sprite_scale; double sprite_scale;

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/15 15:30:27 by qmennen #+# #+# */ /* Created: 2025/04/15 15:30:27 by qmennen #+# #+# */
/* Updated: 2025/05/14 18:31:32 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:19:21 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -58,13 +58,26 @@ void fill_background(t_screen *screen, int color)
} }
} }
int screen_display(t_screen *screen) int center_window(t_screen *screen)
{ {
int m_width; int m_width;
int m_height; int m_height;
m_width = 0; m_width = 0;
m_height = 0; m_height = 0;
mlx_get_monitor_size(0, &m_width, &m_height);
if (m_width == 0 || m_height == 0)
{
printf(RED"Failed to retrieve monitor size to center window\n"RESET);
return (FAILURE);
}
mlx_set_window_pos(screen->mlx, (m_width - screen->width) / 2,
(m_height - screen->height) / 2);
return (SUCCESS);
}
int screen_display(t_screen *screen)
{
fill_background(screen, 0x000000FF); fill_background(screen, 0x000000FF);
if (mlx_image_to_window(screen->mlx, screen->background, 0, 0) < 0) if (mlx_image_to_window(screen->mlx, screen->background, 0, 0) < 0)
{ {
@ -86,12 +99,7 @@ int screen_display(t_screen *screen)
printf(RED"Failed to display buffer image\n"RESET); printf(RED"Failed to display buffer image\n"RESET);
return (FAILURE); return (FAILURE);
} }
mlx_get_monitor_size(0, &m_width, &m_height); if (!center_window(screen))
if (m_width == 0 || m_height == 0)
{
printf(RED"Failed to retrieve monitor size to center window\n"RESET);
return (FAILURE); return (FAILURE);
}
mlx_set_window_pos(screen->mlx, (m_width - screen->width) / 2, (m_height - screen->height) / 2);
return (SUCCESS); return (SUCCESS);
} }

View File

@ -3,18 +3,18 @@
/* :::::::: */ /* :::::::: */
/* texutre_load.c :+: :+: */ /* texutre_load.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/05/06 15:45:58 by qmennen #+# #+# */ /* Created: 2025/05/06 15:45:58 by qmennen #+# #+# */
/* Updated: 2025/05/14 12:48:03 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:01:57 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "texture.h" #include "texture.h"
void texture_delete(t_game *game) void texture_delete(t_game *game)
{ {
int i; int i;
i = 0; i = 0;
while (i < 4) while (i < 4)
@ -35,7 +35,7 @@ void texture_delete(t_game *game)
} }
} }
int texture_load(t_game *game) int texture_load(t_game *game)
{ {
game->map->textures[SIDE_NORTH] = mlx_load_png(game->map->north_texture); game->map->textures[SIDE_NORTH] = mlx_load_png(game->map->north_texture);
game->map->textures[SIDE_EAST] = mlx_load_png(game->map->east_texture); game->map->textures[SIDE_EAST] = mlx_load_png(game->map->east_texture);
@ -43,7 +43,8 @@ int texture_load(t_game *game)
game->map->textures[SIDE_WEST] = mlx_load_png(game->map->west_texture); game->map->textures[SIDE_WEST] = mlx_load_png(game->map->west_texture);
game->map->texture_floor = mlx_load_png("./assets/floor.png"); game->map->texture_floor = mlx_load_png("./assets/floor.png");
game->map->texture_ceiling = mlx_load_png("./assets/ceiling64x64.png"); game->map->texture_ceiling = mlx_load_png("./assets/ceiling64x64.png");
if (!game->map->textures[SIDE_NORTH] || !game->map->textures[SIDE_EAST] || !game->map->textures[SIDE_SOUTH] || !game->map->textures[SIDE_WEST]) if (!game->map->textures[SIDE_NORTH] || !game->map->textures[SIDE_EAST]
|| !game->map->textures[SIDE_SOUTH] || !game->map->textures[SIDE_WEST])
{ {
texture_delete(game); texture_delete(game);
return (FAILURE); return (FAILURE);

View File

@ -3,72 +3,50 @@
/* :::::::: */ /* :::::::: */
/* initialize.c :+: :+: */ /* initialize.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/22 17:08:26 by qmennen #+# #+# */ /* Created: 2025/04/22 17:08:26 by qmennen #+# #+# */
/* Updated: 2025/05/12 12:51:27 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:33:11 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "cub3d.h" #include "cub3d.h"
static t_sprite make_sprite(char *path, double x, double y, int n)
{
t_sprite sprite;
sprite.texture = mlx_load_png(path);
sprite.n_frames = n;
sprite.pos.x = x;
sprite.pos.y = y;
sprite.dist = 0;
sprite.cam_frac = 0;
sprite.alpha = 0;
return (sprite);
}
static int init_temp(t_game **game) static int init_temp(t_game **game)
{ {
t_sprite *sprites;
(*game)->map->sprites = malloc(sizeof(t_sprite) * 10); (*game)->map->sprites = malloc(sizeof(t_sprite) * 10);
if (!(*game)->map->sprites) if (!(*game)->map->sprites)
return (FAILURE); return (FAILURE);
(*game)->map->sprites[0].n_frames = 1; sprites = (*game)->map->sprites;
(*game)->map->sprites[0].pos.x = 3.5; sprites[0] = make_sprite("./assets/battery.png", 3.5, 3.5, 1);
(*game)->map->sprites[0].pos.y = 3.5; sprites[1] = make_sprite("./assets/battery.png", 2.5, 3.5, 1);
(*game)->map->sprites[0].dist = 0; sprites[2] = make_sprite("./assets/battery.png", 1.5, 3.5, 1);
(*game)->map->sprites[0].texture = mlx_load_png("./assets/battery.png"); sprites[3] = make_sprite("./assets/broken_mirror.png", 3.5, 4.5, 1);
(*game)->map->sprites[1].n_frames = 1; sprites[4] = make_sprite("./assets/lamp.png", 2.5, 5.5, 1);
(*game)->map->sprites[1].pos.x = 2.5; sprites[5] = make_sprite("./assets/battery.png", 10.5, 6.5, 1);
(*game)->map->sprites[1].pos.y = 3.5; sprites[6] = make_sprite("./assets/battery.png", 14.5, 3.5, 1);
(*game)->map->sprites[1].dist = 0; sprites[7] = make_sprite("./assets/battery.png", 36.5, 3.5, 1);
(*game)->map->sprites[1].texture = mlx_load_png("./assets/battery.png"); sprites[8] = make_sprite("./assets/broken_mirror.png", 42.5, 4.5, 1);
(*game)->map->sprites[2].n_frames = 1; sprites[9] = make_sprite("./assets/lamp.png", 9.5, 10.5, 1);
(*game)->map->sprites[2].pos.x = 1.5;
(*game)->map->sprites[2].pos.y = 3.5;
(*game)->map->sprites[2].dist = 0;
(*game)->map->sprites[2].texture = mlx_load_png("./assets/battery.png");
(*game)->map->sprites[3].n_frames = 1;
(*game)->map->sprites[3].pos.x = 3.5;
(*game)->map->sprites[3].pos.y = 4.5;
(*game)->map->sprites[3].dist = 0;
(*game)->map->sprites[3].texture = mlx_load_png("./assets/broken_mirror.png");
(*game)->map->sprites[4].n_frames = 1;
(*game)->map->sprites[4].pos.x = 2.5;
(*game)->map->sprites[4].pos.y = 5.5;
(*game)->map->sprites[4].dist = 0;
(*game)->map->sprites[4].texture = mlx_load_png("./assets/lamp.png");
(*game)->map->sprites[5].n_frames = 1;
(*game)->map->sprites[5].pos.x = 10.5;
(*game)->map->sprites[5].pos.y = 6.5;
(*game)->map->sprites[5].dist = 0;
(*game)->map->sprites[5].texture = mlx_load_png("./assets/battery.png");
(*game)->map->sprites[6].n_frames = 1;
(*game)->map->sprites[6].pos.x = 14.5;
(*game)->map->sprites[6].pos.y = 3.5;
(*game)->map->sprites[6].dist = 0;
(*game)->map->sprites[6].texture = mlx_load_png("./assets/battery.png");
(*game)->map->sprites[7].n_frames = 1;
(*game)->map->sprites[7].pos.x = 36.5;
(*game)->map->sprites[7].pos.y = 3.5;
(*game)->map->sprites[7].dist = 0;
(*game)->map->sprites[7].texture = mlx_load_png("./assets/battery.png");
(*game)->map->sprites[8].n_frames = 1;
(*game)->map->sprites[8].pos.x = 42.5;
(*game)->map->sprites[8].pos.y = 4.5;
(*game)->map->sprites[8].dist = 0;
(*game)->map->sprites[8].texture = mlx_load_png("./assets/broken_mirror.png");
(*game)->map->sprites[9].n_frames = 1;
(*game)->map->sprites[9].pos.x = 9.5;
(*game)->map->sprites[9].pos.y = 10.5;
(*game)->map->sprites[9].dist = 0;
(*game)->map->sprites[9].texture = mlx_load_png("./assets/lamp.png");
(*game)->map->n_sprites = 10; (*game)->map->n_sprites = 10;
(*game)->screen->hud = mlx_texture_to_image((*game)->screen->mlx, mlx_load_png("./assets/overlay2.png")); (*game)->screen->hud = mlx_texture_to_image((*game)->screen->mlx,
mlx_load_png("./assets/overlay2.png"));
return (SUCCESS); return (SUCCESS);
} }

View File

@ -3,15 +3,16 @@
/* :::::::: */ /* :::::::: */
/* keyboard.c :+: :+: */ /* keyboard.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/04/17 19:29:29 by qmennen #+# #+# */ /* Created: 2025/04/17 19:29:29 by qmennen #+# #+# */
/* Updated: 2025/05/07 11:35:41 by whaffman ######## odam.nl */ /* Updated: 2025/05/14 20:01:04 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "keyboard.h" #include "keyboard.h"
// TODO: Better
int keyboard_create(t_game **game) int keyboard_create(t_game **game)
{ {
t_keyboard *keyboard; t_keyboard *keyboard;
@ -22,7 +23,7 @@ int keyboard_create(t_game **game)
return (FAILURE); return (FAILURE);
(*game)->keyboard = keyboard; (*game)->keyboard = keyboard;
i = 0; i = 0;
while (i < NUM_KEYS) // TODO: Better while (i < NUM_KEYS)
{ {
(*game)->keyboard->keys[i] = 0; (*game)->keyboard->keys[i] = 0;
i++; i++;