summaryrefslogtreecommitdiff
path: root/src/player_process.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-05-15 14:04:28 +0200
committerDominik Kaiser2024-05-15 14:04:28 +0200
commite6edad24c9fa56538d66067dcff6bde39f746239 (patch)
treef0c4d9a98a087d44334374332b7f3a40380753ea /src/player_process.c
parent012afb95fd1cb5c7e625b4b023c98573c0e0499f (diff)
downloadso_long-e6edad24c9fa56538d66067dcff6bde39f746239.tar.gz
so_long-e6edad24c9fa56538d66067dcff6bde39f746239.zip
Add gravity and jumping
Diffstat (limited to 'src/player_process.c')
-rw-r--r--src/player_process.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/player_process.c b/src/player_process.c
index 52277f8..7e27530 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 12:03:52 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 13:53:01 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,12 +21,12 @@ void player_process(t_game *game)
player = &game->player;
player->direction = get_direction_from_input(game);
- player->velocity.x = player->direction.x * PLAYER_MOVE_SPEED
- * game->mlx->delta_time;
- player->velocity.y = player->direction.y * PLAYER_MOVE_SPEED
- * game->mlx->delta_time;
-
- move_and_slide(player, &game->map);
+ player->velocity.x = player->direction.x * PLAYER_MOVE_SPEED;
+ player->velocity.y += 50;
+ if (player->direction.y == -1 && is_on_floor(player->position, player->size,
+ &game->map))
+ player->velocity.y = -1000;
+ move_and_slide(player, &game->map, game->mlx->delta_time);
}
static t_vector get_direction_from_input(t_game *game)