controller.jump

This commit is contained in:
Mike Schwörer 2017-05-17 20:43:08 +02:00
parent cc07e4d919
commit 5ad0e5902a
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
5 changed files with 18 additions and 19 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="500" height="20" tilewidth="16" tileheight="16" nextobjectid="1">
<tileset firstgid="1" name="Tileset" tilewidth="16" tileheight="16" tilecount="100" columns="10">
<tileset firstgid="1" name="Tileset" tilewidth="16" tileheight="16" tilecount="100">
<image source="../../../data/Tileset.png" width="160" height="160"/>
</tileset>
<layer name="Kachelebene" width="500" height="20">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="500" height="20" tilewidth="16" tileheight="16" nextobjectid="1">
<tileset firstgid="1" name="Tileset" tilewidth="16" tileheight="16" tilecount="100" columns="10">
<tileset firstgid="1" name="Tileset" tilewidth="16" tileheight="16" tilecount="100">
<image source="../../../data/Tileset.png" width="160" height="160"/>
</tileset>
<layer name="Kachelebene" width="500" height="20">
@ -7517,7 +7517,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="13"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -8017,7 +8017,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="13"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -8517,7 +8517,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="13"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -9017,7 +9017,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="13"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}
}