get the Triggers

This commit is contained in:
Armin Benz 2017-04-25 18:44:34 +02:00
parent 811143d192
commit ee91769e84
5 changed files with 48 additions and 3 deletions

View File

@ -1,10 +1,12 @@
package de.samdev.colorrunner.game.world.entities;
import de.samdev.colorrunner.game.world.CRGameWorld;
import de.samdev.colorrunner.game.world.entities.gameentities.GetTriggerType;
public abstract class GravityEntity extends MovingEntity {
public final static float GRAVITY_FORCE = 700f;
public float GRAVITY_FORCE = 700f;
public final static float TERMINAL_VELOCITY = 900f;
public GetTriggerType getType = GetTriggerType.RUNBOTTOM;
public GravityEntity(CRGameWorld _owner, float width, float height) {
this(_owner, 0, 0, width, height);
@ -16,6 +18,19 @@ public abstract class GravityEntity extends MovingEntity {
@Override
public void update(float delta) {
switch (getType){
case RUNTOP:
GRAVITY_FORCE = -700;
break;
case RUNBOTTOM:
GRAVITY_FORCE = 700;
break;
case FLY:
GRAVITY_FORCE = 400;
break;
}
velocity.y -= GRAVITY_FORCE * delta;
if (velocity.y < -TERMINAL_VELOCITY) {

View File

@ -0,0 +1,9 @@
package de.samdev.colorrunner.game.world.entities.gameentities;
/**
* Created by benza on 23.04.2017.
*/
public enum GetTriggerType {
RUNBOTTOM, RUNTOP, FLY, NOTHING
}

View File

@ -10,8 +10,11 @@ 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;
import de.samdev.colorrunner.game.world.map.provider.TriggerType;
import de.samdev.colorrunner.screens.menu.MainMenu;
import static de.samdev.colorrunner.game.world.map.provider.TriggerType.RUNTOP;
public class PlayerEntity extends GravityEntity {
public final static float PLAYER_WIDTH = 32;
public final static float PLAYER_HEIGHT = 32;
@ -26,7 +29,10 @@ public class PlayerEntity extends GravityEntity {
private SwipeDirection phase = SwipeDirection.UP;
private boolean doFly = false;
private TriggerType triggerType;
public PlayerEntity(CRGameWorld _owner, float x, float y) {
super(_owner, x, y, PLAYER_WIDTH, PLAYER_HEIGHT);
@ -43,6 +49,21 @@ public class PlayerEntity extends GravityEntity {
updateRotation(delta);
triggerType = world.mapprovider.getTrigger((int)(bounds.x / FloorTileEntity.FLOORTILE_WIDTH), (int)(bounds.y / FloorTileEntity.FLOORTILE_HEIGHT));
switch (triggerType){
case RUNTOP:
getType = GetTriggerType.RUNTOP;
break;
case RUNBOTTOM:
getType = GetTriggerType.RUNBOTTOM;
break;
case FLY:
getType = GetTriggerType.FLY;
break;
}
super.update(delta);
}

View File

@ -14,5 +14,5 @@ public abstract class MapProvider {
public abstract MapProvider createNew();
public abstract Enum<TriggerType> getTrigger(int x, int y);
public abstract TriggerType getTrigger(int x, int y);
}

View File

@ -95,12 +95,12 @@ public class CRGameInputProcessor implements InputProcessor, GestureListener {
@Override
public boolean touchDown(float x, float y, int pointer, int button) {
owner.doJump();
return false;
}
@Override
public boolean tap(float x, float y, int count, int button) {
owner.doJump();
return false;
}