From 5ad0e5902a40f3498ccf6b44256c8edc987417f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Wed, 17 May 2017 20:43:08 +0200 Subject: [PATCH] controller.jump --- android/assets/levels/plevel001.tmx | 2 +- android/assets/levels/plevel002.tmx | 10 +++++----- .../controller/AbstractPlayerController.java | 3 ++- .../controller/RunBottomPlayerController.java | 11 +++++------ .../controller/RunTopPlayerController.java | 11 +++++------ 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/android/assets/levels/plevel001.tmx b/android/assets/levels/plevel001.tmx index d62d5ca..94a7c3f 100644 --- a/android/assets/levels/plevel001.tmx +++ b/android/assets/levels/plevel001.tmx @@ -1,6 +1,6 @@ - + diff --git a/android/assets/levels/plevel002.tmx b/android/assets/levels/plevel002.tmx index c6ea01a..38fa785 100644 --- a/android/assets/levels/plevel002.tmx +++ b/android/assets/levels/plevel002.tmx @@ -1,6 +1,6 @@ - + @@ -7517,7 +7517,7 @@ - + @@ -8017,7 +8017,7 @@ - + @@ -8517,7 +8517,7 @@ - + @@ -9017,7 +9017,7 @@ - + diff --git a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/AbstractPlayerController.java b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/AbstractPlayerController.java index 2dbba93..3f2d208 100644 --- a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/AbstractPlayerController.java +++ b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/AbstractPlayerController.java @@ -7,7 +7,8 @@ public abstract class AbstractPlayerController { public float GRAVITY_FORCE = 700f; public final static float TERMINAL_VELOCITY = 900f; - public final static float PLAYER_JUMP_FORCE = 356f; + public final static float PLAYER_JUMP_FORCE_INITIAL = 200f; + public final static float PLAYER_JUMP_FORCE_AIR = 500f; public final static float PLAYER_FLY_UP_FORCE = 350f; protected final PlayerEntity Player; diff --git a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/RunBottomPlayerController.java b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/RunBottomPlayerController.java index b25119a..b81b061 100644 --- a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/RunBottomPlayerController.java +++ b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/RunBottomPlayerController.java @@ -16,14 +16,13 @@ public class RunBottomPlayerController extends AbstractPlayerController { @Override public void update(float delta) { boolean down = Gdx.input.isKeyPressed(Input.Keys.SPACE) || Gdx.input.isTouched(); -/* - if (!down && isJumping) { - if (Player.velocity.y > 0) Player.velocity.y = 0; + + if (down && isJumping && Player.velocity.y > 0) { + Player.velocity.y += PLAYER_JUMP_FORCE_AIR * delta; + } else { isJumping = false; } - if (! down) isJumping = false; -*/ Player.velocity.y -= GRAVITY_FORCE * delta; if (Player.velocity.y < -TERMINAL_VELOCITY) { @@ -42,7 +41,7 @@ public class RunBottomPlayerController extends AbstractPlayerController { @Override public void jumpPressed() { if (Player.isTouching_BOTTOM()) { - Player.velocity.y = PLAYER_JUMP_FORCE; + Player.velocity.y = PLAYER_JUMP_FORCE_INITIAL; isJumping = true; } } diff --git a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/RunTopPlayerController.java b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/RunTopPlayerController.java index 7f2e477..7715b13 100644 --- a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/RunTopPlayerController.java +++ b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/RunTopPlayerController.java @@ -16,14 +16,13 @@ public class RunTopPlayerController extends AbstractPlayerController { @Override public void update(float delta) { boolean down = Gdx.input.isKeyPressed(Input.Keys.SPACE) || Gdx.input.isTouched(); -/* - if (!down && isJumping) { - if (Player.velocity.y < 0) Player.velocity.y = 0; + + if (down && isJumping && Player.velocity.y < 0) { + Player.velocity.y -= PLAYER_JUMP_FORCE_AIR * delta; + } else { isJumping = false; } - if (! down) isJumping = false; -*/ Player.velocity.y += GRAVITY_FORCE * delta; if (Player.velocity.y > TERMINAL_VELOCITY) { @@ -42,7 +41,7 @@ public class RunTopPlayerController extends AbstractPlayerController { @Override public void jumpPressed() { if (Player.isTouching_TOP()) { - Player.velocity.y = -PLAYER_JUMP_FORCE; + Player.velocity.y = -PLAYER_JUMP_FORCE_INITIAL; isJumping = true; } }