summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/so_long.h10
-rw-r--r--src/collision.c24
-rw-r--r--src/init.c10
-rw-r--r--src/player_process.c4
4 files changed, 24 insertions, 24 deletions
diff --git a/include/so_long.h b/include/so_long.h
index 48c34aa..4118166 100644
--- a/include/so_long.h
+++ b/include/so_long.h
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/08 14:14:02 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 14:04:06 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 14:48:10 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -50,14 +50,14 @@ typedef struct s_ivector
int y;
} t_ivector;
-typedef struct s_player
+typedef struct s_actor
{
t_vector position;
t_vector direction;
t_vector velocity;
t_ivector size;
mlx_image_t *img;
-} t_player;
+} t_actor;
typedef struct s_tilemap
{
@@ -72,7 +72,7 @@ typedef struct s_game
{
mlx_t *mlx;
void *window;
- t_player player;
+ t_actor player;
int input_direction;
t_tilemap map;
} t_game;
@@ -92,7 +92,7 @@ int check_collision(t_vector a_pos, t_ivector a_size,
t_vector b_pos, t_ivector b_size);
int check_wall_collision(t_vector a_pos, t_ivector a_size,
t_tilemap *map);
-void move_and_slide(t_player *player, t_tilemap *map,
+void move_and_slide(t_actor *actor, t_tilemap *map,
double delta_time);
int is_on_floor(t_vector pos, t_ivector size, t_tilemap *map);
diff --git a/src/collision.c b/src/collision.c
index 5c16130..4458d60 100644
--- a/src/collision.c
+++ b/src/collision.c
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/14 11:48:59 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 13:20:29 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 14:47:26 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -84,24 +84,24 @@ static int check_wall_collision_with_cell(t_vector a_pos, t_ivector a_size,
return (0);
}
-void move_and_slide(t_player *player, t_tilemap *map, double delta_time)
+void move_and_slide(t_actor *actor, t_tilemap *map, double delta_time)
{
t_vector move_pos;
- move_pos.x = player->position.x + (player->velocity.x * delta_time);
- move_pos.y = player->position.y;
+ move_pos.x = actor->position.x + (actor->velocity.x * delta_time);
+ move_pos.y = actor->position.y;
- if ((check_wall_collision(move_pos, player->size, map) & (RIGHT | LEFT)) == 0)
- player->position.x = move_pos.x;
+ if ((check_wall_collision(move_pos, actor->size, map) & (RIGHT | LEFT)) == 0)
+ actor->position.x = move_pos.x;
else
- player->velocity.x = 0;
+ actor->velocity.x = 0;
- move_pos.x = player->position.x;
- move_pos.y = player->position.y + (player->velocity.y * delta_time);
- if ((check_wall_collision(move_pos, player->size, map) & (UP | DOWN)) == 0)
- player->position.y = move_pos.y;
+ move_pos.x = actor->position.x;
+ move_pos.y = actor->position.y + (actor->velocity.y * delta_time);
+ if ((check_wall_collision(move_pos, actor->size, map) & (UP | DOWN)) == 0)
+ actor->position.y = move_pos.y;
else
- player->velocity.y = 0;
+ actor->velocity.y = 0;
}
int is_on_floor(t_vector pos, t_ivector size, t_tilemap *map)
diff --git a/src/init.c b/src/init.c
index 9959da6..9926826 100644
--- a/src/init.c
+++ b/src/init.c
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/09 14:50:09 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 12:13:03 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 14:46:09 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,7 +14,7 @@
#include "so_long.h"
static void init_hooks(t_game *game);
-static void init_player(t_game *game);
+static void init_actor(t_game *game);
int init(t_game *game)
{
@@ -23,7 +23,7 @@ int init(t_game *game)
// TODO: make size and title dynamic
game->input_direction = ZERO;
init_hooks(game);
- init_player(game);
+ init_actor(game);
return (0);
}
@@ -33,10 +33,10 @@ static void init_hooks(t_game *game)
mlx_key_hook(game->mlx, on_key_input, game);
}
-static void init_player(t_game *game)
+static void init_actor(t_game *game)
{
mlx_texture_t *texture;
- t_player *player;
+ t_actor *player;
player = &game->player;
texture = mlx_load_png("textures/player.png");
diff --git a/src/player_process.c b/src/player_process.c
index 7e27530..c66d13d 100644
--- a/src/player_process.c
+++ b/src/player_process.c
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/14 12:40:05 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 13:53:01 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 14:46:26 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,7 +17,7 @@ static t_vector get_direction_from_input(t_game *game);
void player_process(t_game *game)
{
- t_player *player;
+ t_actor *player;
player = &game->player;
player->direction = get_direction_from_input(game);