]> git.dkaiser.de - 42/so_long.git/commitdiff
Rename t_player to t_actor
authorDominik Kaiser <dkaiser@1-C-7.42heilbronn.de>
Wed, 15 May 2024 12:49:40 +0000 (14:49 +0200)
committerDominik Kaiser <dkaiser@1-C-7.42heilbronn.de>
Wed, 15 May 2024 12:49:40 +0000 (14:49 +0200)
include/so_long.h
src/collision.c
src/init.c
src/player_process.c

index 48c34aa1385790d4f2800d74e973eff05f1928c1..41181664c084b0bf95e81647802d306d190d8bf1 100644 (file)
@@ -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);
 
index 5c16130856ebdaba3d42ae111b59cf60f8382193..4458d606fe7c88313cebb98f47b4cbfe0114180e 100644 (file)
@@ -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)
index 9959da60996a54348fe5b02151e78fdcf6c8c68d..99268261985143602d42aa60be93ea9447da379d 100644 (file)
@@ -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");
index 7e27530ea6b623cd610b443ca3fde6c539b8ce52..c66d13d052c898282ce8d3092e1b1d485fa7988e 100644 (file)
@@ -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);