]> git.dkaiser.de - 42/so_long.git/commitdiff
Make norminette happy
authorDominik Kaiser <dkaiser@1-C-7.42heilbronn.de>
Fri, 10 May 2024 10:17:52 +0000 (12:17 +0200)
committerDominik Kaiser <dkaiser@1-C-7.42heilbronn.de>
Fri, 10 May 2024 10:17:52 +0000 (12:17 +0200)
src/init.c
src/input.c
src/loop.c

index d72f486282bf1bbb5369c69e368f7974b29cce57..bd6b48fe021c6d42e8a460d6564c647845312cf1 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/05/09 14:50:09 by dkaiser           #+#    #+#             */
-/*   Updated: 2024/05/10 12:11:01 by dkaiser          ###   ########.fr       */
+/*   Updated: 2024/05/10 12:13:33 by dkaiser          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -17,15 +17,18 @@ static void init_player(t_player *player, int x, int y);
 
 int    init(t_game *game)
 {
+       mlx_texture_t   *texture;
+
        game->mlx = mlx_init(1920, 1080, "so_long", false);
        // TODO: make size and title dynamic
        game->input_direction = ZERO;
        init_hooks(game);
        init_player(&game->player, 960, 540);
        // TODO: make player spawn point dynamic
-       mlx_texture_t *texture = mlx_load_png("textures/player.png");
+       texture = mlx_load_png("textures/player.png");
        game->player.img = mlx_texture_to_image(game->mlx, texture);
-       mlx_image_to_window(game->mlx, game->player.img, game->player.position.x, game->player.position.y);
+       mlx_image_to_window(game->mlx, game->player.img, game->player.position.x,
+               game->player.position.y);
        return (0);
 }
 
index 40c567016c17555f9be9486f5c518168ae0dccde..a6cb8d443afd81a9af46436ac77fd6d39df2f419 100644 (file)
@@ -6,17 +6,17 @@
 /*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/05/09 15:37:40 by dkaiser           #+#    #+#             */
-/*   Updated: 2024/05/10 12:11:48 by dkaiser          ###   ########.fr       */
+/*   Updated: 2024/05/10 12:13:22 by dkaiser          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
 #include "so_long.h"
 
-void on_key_input(mlx_key_data_t event, void *params)
+void   on_key_input(mlx_key_data_t event, void *params)
 {
-       t_game *game;
+       t_game  *game;
 
-       game = (t_game *) params;
+       game = (t_game *)params;
        if (event.action == MLX_PRESS)
        {
                if (event.key == MLX_KEY_W || event.key == MLX_KEY_UP)
index e994bc00be35af4b5f9f50872c566ee4431047e6..6162935b6af58c002647c87896e7efe625bb2444 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/05/09 15:09:24 by dkaiser           #+#    #+#             */
-/*   Updated: 2024/05/10 11:17:33 by dkaiser          ###   ########.fr       */
+/*   Updated: 2024/05/10 12:17:03 by dkaiser          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
 
 void   loop(void *params)
 {
-    t_game *game;
+       t_game  *game;
 
-    game = (t_game *) params;
+       game = (t_game *)params;
        game->player.direction.x = ((game->input_direction & RIGHT) != 0)
                - ((game->input_direction & LEFT) != 0);
        game->player.direction.y = ((game->input_direction & DOWN) != 0)
                - ((game->input_direction & UP) != 0);
-
-    game->player.position.x += game->player.direction.x * PLAYER_MOVE_SPEED;
-    game->player.position.y += game->player.direction.y * PLAYER_MOVE_SPEED;
-
-    draw(game);
+       game->player.position.x += game->player.direction.x * PLAYER_MOVE_SPEED;
+       game->player.position.y += game->player.direction.y * PLAYER_MOVE_SPEED;
+       draw(game);
 }