From 7772c7e82e90c940982452470c00680e4081cbf7 Mon Sep 17 00:00:00 2001 From: Marcos Sevilla <31174242+marcossevilla@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:55:14 +0200 Subject: [PATCH] fix: player jumping when in ground (#14) --- lib/game/behaviors/player_keyboard_controller_behavior.dart | 2 +- lib/game/components/player.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/game/behaviors/player_keyboard_controller_behavior.dart b/lib/game/behaviors/player_keyboard_controller_behavior.dart index 082a0d47..226a4c1a 100644 --- a/lib/game/behaviors/player_keyboard_controller_behavior.dart +++ b/lib/game/behaviors/player_keyboard_controller_behavior.dart @@ -9,7 +9,7 @@ class PlayerKeyboardControllerBehavior extends Behavior { if (parent.isAlive) { // Keep jumping if started. - if (parent.jumping && parent.input.isPressed) { + if (parent.jumping && parent.input.isPressed && parent.isOnGround) { parent.jumping = true; } else { parent.jumping = false; diff --git a/lib/game/components/player.dart b/lib/game/components/player.dart index f8731121..5f1fd882 100644 --- a/lib/game/components/player.dart +++ b/lib/game/components/player.dart @@ -52,8 +52,8 @@ class Player extends JumperCharacter { input = gameRef.input; size = Vector2.all(gameRef.tileSize); - walkSpeed = gameRef.tileSize * 7; - minJumpImpulse = world.gravity * 0.6; + walkSpeed = gameRef.tileSize * 5; + minJumpImpulse = world.gravity * 0.7; cameraAnchor = PlayerCameraAnchor(); add(cameraAnchor);