player jump with touch, level02,

This commit is contained in:
Armin Benz 2017-04-30 21:21:53 +02:00
parent 4b4599e5b8
commit 6aee1e0ea7
10 changed files with 20036 additions and 18 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,6 @@ import de.samdev.colorrunner.CRGame;
import de.samdev.colorrunner.game.world.CRGameWorld;
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
import de.samdev.colorrunner.game.world.entities.MovingEntity;
import de.samdev.colorrunner.game.world.entities.StaticEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity;
import de.samdev.colorrunner.game.world.map.provider.EndlessMapProvider;
import de.samdev.colorrunner.game.world.map.provider.StaticMapProvider;
@ -152,6 +151,7 @@ public class CRGameRenderer extends AbstractGameRenderer {
renderDebug("Player(tile): [" + (int)(gameworld.player.bounds.x / FloorTileEntity.FLOORTILE_WIDTH) + "|" + (int)(gameworld.player.bounds.y / FloorTileEntity.FLOORTILE_WIDTH) + "]");
renderDebug("Player(trigger): " + gameworld.mapprovider.getTrigger((int)(gameworld.player.bounds.x / FloorTileEntity.FLOORTILE_WIDTH), (int)(gameworld.player.bounds.y / FloorTileEntity.FLOORTILE_WIDTH)));
renderDebug("Player(velo): [" + gameworld.player.velocity.x + " | " + gameworld.player.velocity.y + "]");
endDebug();
}

View File

@ -160,6 +160,8 @@ public abstract class MovingEntity extends CRGameEntity {
}
}
if (getFirstCollision() != null) return true; // collision but expansion failed
bounds.set(next);
return true;
} else {
@ -233,6 +235,8 @@ public abstract class MovingEntity extends CRGameEntity {
}
}
if (getFirstCollision() != null) return true; // collision but expansion failed
bounds.set(next);
return true;
} else {

View File

@ -9,9 +9,9 @@ import de.samdev.colorrunner.game.world.SwipeDirection;
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
import de.samdev.colorrunner.game.world.entities.MovingEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.controller.AbstractPlayerController;
import de.samdev.colorrunner.game.world.entities.gameentities.controller.DefaultPlayerController;
import de.samdev.colorrunner.game.world.entities.gameentities.controller.FlyingPlayerController;
import de.samdev.colorrunner.game.world.entities.gameentities.controller.InvertedPlayerController;
import de.samdev.colorrunner.game.world.entities.gameentities.controller.RunBottomPlayerController;
import de.samdev.colorrunner.game.world.entities.gameentities.controller.FlyPlayerController;
import de.samdev.colorrunner.game.world.entities.gameentities.controller.RunTopPlayerController;
import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity;
import de.samdev.colorrunner.game.world.map.provider.TriggerType;
@ -31,7 +31,7 @@ public class PlayerEntity extends MovingEntity {
public PlayerEntity(CRGameWorld _owner, float x, float y) {
super(_owner, x, y, PLAYER_WIDTH, PLAYER_HEIGHT);
controller = new DefaultPlayerController(this);
controller = new RunBottomPlayerController(this);
}
@Override
@ -44,13 +44,13 @@ public class PlayerEntity extends MovingEntity {
TriggerType trigger = world.mapprovider.getTrigger((int)((bounds.x + bounds.width/2f) / FloorTileEntity.FLOORTILE_WIDTH), (int)((bounds.y + bounds.height/2f) / FloorTileEntity.FLOORTILE_HEIGHT));
switch (trigger){
case RUNTOP:
if (controller.getControllerType() != ControllingType.RUNTOP) controller = new InvertedPlayerController(this);
if (controller.getControllerType() != ControllingType.RUNTOP) controller = new RunTopPlayerController(this);
break;
case RUNBOTTOM:
if (controller.getControllerType() != ControllingType.RUNBOTTOM) controller = new DefaultPlayerController(this);
if (controller.getControllerType() != ControllingType.RUNBOTTOM) controller = new RunBottomPlayerController(this);
break;
case FLY:
if (controller.getControllerType() != ControllingType.FLY) controller = new FlyingPlayerController(this);
if (controller.getControllerType() != ControllingType.FLY) controller = new FlyPlayerController(this);
break;
}

View File

@ -8,7 +8,7 @@ public abstract class AbstractPlayerController {
public final static float TERMINAL_VELOCITY = 900f;
public final static float PLAYER_JUMP_FORCE = 356f;
public final static float PLAYER_FLY_UP_FORCE = 555f;
public final static float PLAYER_FLY_UP_FORCE = 350f;
protected final PlayerEntity Player;

View File

@ -3,8 +3,8 @@ package de.samdev.colorrunner.game.world.entities.gameentities.controller;
import de.samdev.colorrunner.game.world.entities.gameentities.ControllingType;
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
public class FlyingPlayerController extends AbstractPlayerController {
public FlyingPlayerController(PlayerEntity e) {
public class FlyPlayerController extends AbstractPlayerController {
public FlyPlayerController(PlayerEntity e) {
super(e);
}
@ -27,6 +27,6 @@ public class FlyingPlayerController extends AbstractPlayerController {
@Override
public void jumpPressed() {
Player.velocity.y += PLAYER_FLY_UP_FORCE;
Player.velocity.y = PLAYER_FLY_UP_FORCE;
}
}

View File

@ -6,10 +6,10 @@ import com.badlogic.gdx.Input;
import de.samdev.colorrunner.game.world.entities.gameentities.ControllingType;
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
public class DefaultPlayerController extends AbstractPlayerController {
public class RunBottomPlayerController extends AbstractPlayerController {
private boolean isJumping = false;
public DefaultPlayerController(PlayerEntity e) {
public RunBottomPlayerController(PlayerEntity e) {
super(e);
}

View File

@ -6,10 +6,10 @@ import com.badlogic.gdx.Input;
import de.samdev.colorrunner.game.world.entities.gameentities.ControllingType;
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
public class InvertedPlayerController extends AbstractPlayerController {
public class RunTopPlayerController extends AbstractPlayerController {
private boolean isJumping = false;
public InvertedPlayerController(PlayerEntity e) {
public RunTopPlayerController(PlayerEntity e) {
super(e);
}

View File

@ -38,7 +38,7 @@ public class CRMapStorage {
public static final CRTiledMap map_25 = register("map_pieces", "p25.tmx");
public static final CRTiledMap map_26 = register("map_pieces", "p26.tmx");
public static final CRTiledMap lvl_01 = load("levels", "plevel001.tmx");
public static final CRTiledMap lvl_01 = load("levels", "plevel002.tmx");
private static CRTiledMap load(String folder, String path) {
return internalload(folder, path, false);

View File

@ -67,6 +67,7 @@ public class CRGameInputProcessor implements InputProcessor, GestureListener {
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
owner.doJump();
return false;
}
@ -97,7 +98,6 @@ public class CRGameInputProcessor implements InputProcessor, GestureListener {
@Override
public boolean tap(float x, float y, int count, int button) {
owner.doJump();
return false;
}