added [R]eset

This commit is contained in:
Mike Schwörer 2014-08-11 21:36:01 +02:00
parent 453d50f1c0
commit a2d19985e7
4 changed files with 29 additions and 3 deletions

View File

@ -48,6 +48,12 @@ public abstract class AbstractGameRenderer {
cam.update();
updateCamMatrices();
}
if (lookAtX < cam.position.x - cam.viewportWidth/2) {
cam.position.x += lookAtX - cam.position.x + cam.viewportWidth/2;
cam.update();
updateCamMatrices();
}
}
public Rectangle getCamViewRectangle() {

View File

@ -24,8 +24,8 @@ import de.samdev.colorrunner.input.GameInputListener;
public class CRGameWorld implements GameInputListener {
public PlayerEntity player;
public List<CRGameEntity> entities = new ArrayList<CRGameEntity>();
public List<MapSection> sections = new ArrayList<MapSection>();
public List<CRGameEntity> entities;
public List<MapSection> sections;
public FPSCounter fps = new FPSCounter();
@ -34,9 +34,16 @@ public class CRGameWorld implements GameInputListener {
public Rectangle camViewBoundaries = new Rectangle();
public CRGameWorld() {
reinitialize();
}
private void reinitialize() {
entities = new ArrayList<CRGameEntity>();
sections = new ArrayList<MapSection>();
addEntity(player = new PlayerEntity(this, 40, 290));
mapRightBoundary = appendMap(CRMapStorage.map_start, new Vector2(mapRightBoundary, 0));
mapRightBoundary = appendMap(CRMapStorage.map_start, new Vector2(0, 0));
expandMap();
}
@ -133,4 +140,9 @@ public class CRGameWorld implements GameInputListener {
public void doFly() {
player.fly();
}
@Override
public void reset() {
reinitialize();
}
}

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.input.GestureDetector.GestureListener;
import com.badlogic.gdx.math.Vector2;
import de.samdev.colorrunner.CRGame;
import de.samdev.colorrunner.game.world.SwipeDirection;
public class CRGameInputProcessor implements InputProcessor, GestureListener {
@ -47,6 +48,12 @@ public class CRGameInputProcessor implements InputProcessor, GestureListener {
owner.doJump();
return true;
}
if (keycode == Input.Keys.R && CRGame.DEBUG) {
owner.reset();
return true;
}
return false;
}

View File

@ -6,4 +6,5 @@ public interface GameInputListener {
public void doJump();
public void doFly();
public void switchColor(SwipeDirection sd);
public void reset();
}