Fixed things 4 android

This commit is contained in:
Mike Schwörer 2014-08-11 18:23:07 +02:00
parent 38e018febf
commit 0d66c2dea1
2 changed files with 36 additions and 37 deletions

View File

@ -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() {

View File

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