diff --git a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/PlayerEntity.java b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/PlayerEntity.java index 9b5525e..aed62f2 100644 --- a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/PlayerEntity.java +++ b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/PlayerEntity.java @@ -7,6 +7,7 @@ import de.samdev.colorrunner.game.world.CRGameWorld; import de.samdev.colorrunner.game.world.SwipeDirection; import de.samdev.colorrunner.game.world.entities.CRGameEntity; import de.samdev.colorrunner.game.world.entities.GravityEntity; +import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity; public class PlayerEntity extends GravityEntity { public final static float PLAYER_WIDTH = 32; @@ -26,7 +27,6 @@ public class PlayerEntity extends GravityEntity { public PlayerEntity(CRGameWorld _owner, float x, float y) { super(_owner, x, y, PLAYER_WIDTH, PLAYER_HEIGHT); - } @Override @@ -38,6 +38,12 @@ public class PlayerEntity extends GravityEntity { velocity.y += PLAYER_FLY_FORCE * delta; doFly = false; + updateRotation(delta); + + super.update(delta); + } + + private void updateRotation(float delta) { if (!isTouching_BOTTOM() || visualRotation % 90 != 0) { if (! isTouching_BOTTOM()) { visualRotation = visualRotation + PLAYER_ROTATION_SPEED * delta; @@ -62,8 +68,6 @@ public class PlayerEntity extends GravityEntity { updateHitBox(p, p); } } - - super.update(delta); } public void jump() { @@ -72,7 +76,16 @@ public class PlayerEntity extends GravityEntity { } public void switchPhase(SwipeDirection sd) { + if (phase == sd) return; phase = sd; + + for (CRGameEntity ent : world.entities) { + if (ent == this) continue; + + if (ent.bounds.overlaps(bounds) && ent.canCollide(false, this) && ent instanceof FloorTileEntity) + ent.remove(); + + } } public void fly() { diff --git a/core/src/de/samdev/colorrunner/input/CRGameInputProcessor.java b/core/src/de/samdev/colorrunner/input/CRGameInputProcessor.java index ad68272..3d9fa0a 100644 --- a/core/src/de/samdev/colorrunner/input/CRGameInputProcessor.java +++ b/core/src/de/samdev/colorrunner/input/CRGameInputProcessor.java @@ -53,89 +53,75 @@ public class CRGameInputProcessor implements InputProcessor, GestureListener { @Override public boolean keyUp(int keycode) { - // TODO Auto-generated method stub return false; } @Override public boolean keyTyped(char character) { - // TODO Auto-generated method stub return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { - // TODO Auto-generated method stub return false; } @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { - // TODO Auto-generated method stub return false; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { - // TODO Auto-generated method stub return false; } @Override public boolean mouseMoved(int screenX, int screenY) { - // TODO Auto-generated method stub return false; } @Override public boolean scrolled(int amount) { - // TODO Auto-generated method stub return false; } @Override public boolean touchDown(float x, float y, int pointer, int button) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean tap(float x, float y, int count, int button) { owner.doJump(); return false; } + @Override + public boolean tap(float x, float y, int count, int button) { + return false; + } + @Override public boolean longPress(float x, float y) { - // TODO Auto-generated method stub return false; } @Override public boolean fling(float velocityX, float velocityY, int button) { - if (velocityX == velocityY) return false; - - if (velocityY > Math.abs(velocityX)) { + double angle = Math.atan2(velocityX, velocityY) + Math.PI; + + if (angle < Math.PI * 1/4.0) { + owner.switchColor(SwipeDirection.UP); + return true; + } else if (angle < Math.PI * 3/4.0) { + owner.switchColor(SwipeDirection.LEFT); + return true; + } else if (angle < Math.PI * 5/4.0) { + owner.switchColor(SwipeDirection.DOWN); + return true; + } else if (angle < Math.PI * 7/4.0) { + owner.switchColor(SwipeDirection.RIGHT); + return true; + } else { owner.switchColor(SwipeDirection.UP); return true; } - - if (Math.abs(velocityY) < velocityX) { - owner.switchColor(SwipeDirection.LEFT); - return true; - } - - if (velocityY < Math.abs(velocityX)) { - owner.switchColor(SwipeDirection.DOWN); - return true; - } - - if (Math.abs(velocityY) > velocityX) { - owner.switchColor(SwipeDirection.RIGHT); - return true; - } - - return false; } @Override