2014-08-10 17:19:40 +02:00
|
|
|
package de.samdev.colorrunner.game.world;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-08-10 19:41:06 +02:00
|
|
|
import com.badlogic.gdx.Gdx;
|
|
|
|
|
2014-08-10 17:19:40 +02:00
|
|
|
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
|
|
|
|
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
|
2014-08-10 19:41:06 +02:00
|
|
|
import de.samdev.colorrunner.game.world.entities.gameentities.FloorTileEntity;
|
|
|
|
import de.samdev.colorrunner.input.GameInputListener;
|
|
|
|
import de.samdev.colorrunner.input.SwipeDirection;
|
2014-08-10 17:19:40 +02:00
|
|
|
|
2014-08-10 19:41:06 +02:00
|
|
|
public class CRGameWorld implements GameInputListener {
|
|
|
|
|
|
|
|
public PlayerEntity player;
|
|
|
|
|
2014-08-10 17:19:40 +02:00
|
|
|
public List<CRGameEntity> entities = new ArrayList<CRGameEntity>();
|
|
|
|
|
|
|
|
public FPSCounter fps = new FPSCounter();
|
|
|
|
|
|
|
|
public CRGameWorld() {
|
|
|
|
|
2014-08-10 19:41:06 +02:00
|
|
|
addEntity(player = new PlayerEntity(this, 40, 290));
|
|
|
|
|
|
|
|
addEntity(new FloorTileEntity(this, 1*32, 32));
|
|
|
|
addEntity(new FloorTileEntity(this, 2*32, 32));
|
|
|
|
addEntity(new FloorTileEntity(this, 3*32, 32));
|
|
|
|
addEntity(new FloorTileEntity(this, 4*32, 32));
|
|
|
|
addEntity(new FloorTileEntity(this, 5*32, 32));
|
|
|
|
addEntity(new FloorTileEntity(this, 6*32, 32));
|
|
|
|
addEntity(new FloorTileEntity(this, 7*32, 32));
|
|
|
|
addEntity(new FloorTileEntity(this, 8*32, 32));
|
|
|
|
addEntity(new FloorTileEntity(this, 9*32, 32));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addEntity(new FloorTileEntity(this, 11*32, 456));
|
|
|
|
addEntity(new FloorTileEntity(this, 12*32, 456));
|
|
|
|
addEntity(new FloorTileEntity(this, 13*32, 456));
|
|
|
|
addEntity(new FloorTileEntity(this, 14*32, 456));
|
|
|
|
addEntity(new FloorTileEntity(this, 15*32, 456));
|
|
|
|
addEntity(new FloorTileEntity(this, 16*32, 456));
|
|
|
|
addEntity(new FloorTileEntity(this, 17*32, 456));
|
|
|
|
addEntity(new FloorTileEntity(this, 18*32, 456));
|
|
|
|
addEntity(new FloorTileEntity(this, 19*32, 456));
|
2014-08-10 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void update(float delta) {
|
|
|
|
fps.Inc();
|
|
|
|
|
|
|
|
for (CRGameEntity ent : entities) {
|
|
|
|
ent.update(delta);
|
|
|
|
}
|
|
|
|
// Gdx.app.log("GameWorld", "update FPS[" + (int)fps.getFPS() + "] DELTA:[" + delta + "]");
|
|
|
|
}
|
|
|
|
|
2014-08-10 19:41:06 +02:00
|
|
|
public CRGameEntity addEntity(CRGameEntity ent) {
|
2014-08-10 17:19:40 +02:00
|
|
|
entities.add(ent);
|
2014-08-10 19:41:06 +02:00
|
|
|
|
|
|
|
return ent;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void doJump() {
|
|
|
|
player.jump();
|
|
|
|
|
|
|
|
Gdx.app.log("GameScreen", "[DO] Jump");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void switchColor(SwipeDirection sd) {
|
|
|
|
player.switchPhase(sd);
|
|
|
|
|
|
|
|
Gdx.app.log("GameScreen", "[DO] Switch + " + sd.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void doFly() {
|
|
|
|
player.fly();
|
|
|
|
|
|
|
|
Gdx.app.log("GameScreen", "[DO] Fly");
|
2014-08-10 17:19:40 +02:00
|
|
|
}
|
|
|
|
}
|