diff options
| author | Dominik Kaiser | 2024-05-10 12:17:52 +0200 |
|---|---|---|
| committer | Dominik Kaiser | 2024-05-10 12:17:52 +0200 |
| commit | 7e992a69a2031f630f1e30b0d864c0e4e7d32067 (patch) | |
| tree | c3b0ec31cb6c4cb104579c801bbef0678ab99304 | |
| parent | b114117e5f62761dfecd618432a44e75263a929c (diff) | |
| download | so_long-7e992a69a2031f630f1e30b0d864c0e4e7d32067.tar.gz so_long-7e992a69a2031f630f1e30b0d864c0e4e7d32067.zip | |
Make norminette happy
| -rw-r--r-- | src/init.c | 9 | ||||
| -rw-r--r-- | src/input.c | 8 | ||||
| -rw-r--r-- | src/loop.c | 14 |
3 files changed, 16 insertions, 15 deletions
@@ -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); } diff --git a/src/input.c b/src/input.c index 40c5670..a6cb8d4 100644 --- a/src/input.c +++ b/src/input.c @@ -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) @@ -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 */ /* */ /* ************************************************************************** */ @@ -15,16 +15,14 @@ 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); } |
