ColorRunner/core/src/de/samdev/colorrunner/screens/gameScreen/GameScreen.java

88 lines
2.0 KiB
Java
Raw Normal View History

2014-08-10 00:42:19 +02:00
package de.samdev.colorrunner.screens.gameScreen;
2014-08-10 00:24:45 +02:00
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
2014-08-10 00:24:45 +02:00
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.input.GestureDetector;
2014-08-10 00:24:45 +02:00
2014-08-10 17:19:40 +02:00
import de.samdev.colorrunner.game.renderer.CRGameRenderer;
import de.samdev.colorrunner.game.world.CRGameWorld;
import de.samdev.colorrunner.input.CRGameInputProcessor;
import de.samdev.colorrunner.input.GameInputListener;
import de.samdev.colorrunner.input.SwipeDirection;
2014-08-10 00:24:45 +02:00
public class GameScreen implements Screen, GameInputListener {
2014-08-10 17:19:40 +02:00
private final static float GAME_WIDTH = 500;
2014-08-10 17:19:40 +02:00
private CRGameWorld world;
private CRGameRenderer renderer;
2014-08-10 00:24:45 +02:00
public GameScreen() {
2014-08-10 17:19:40 +02:00
world = new CRGameWorld(); // initialize world
renderer = new CRGameRenderer(world, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // initialize renderer
2014-08-10 00:24:45 +02:00
}
@Override
public void render(float delta) {
2014-08-10 17:19:40 +02:00
world.update(delta);
renderer.render();
2014-08-10 00:24:45 +02:00
}
@Override
public void resize(int width, int height) {
2014-08-10 17:19:40 +02:00
Gdx.app.log("GameScreen", "resize called");
float gameHeight = height / (width / GAME_WIDTH);
float gameX = 0;
float gameY = (height - gameHeight) / 2;
renderer.resize(width, height);
2014-08-10 00:24:45 +02:00
}
@Override
public void show() {
CRGameInputProcessor ip = new CRGameInputProcessor(this);
2014-08-10 17:19:40 +02:00
Gdx.input.setInputProcessor(new InputMultiplexer(ip, new GestureDetector(ip)));
Gdx.app.log("GameScreen", "show called");
2014-08-10 00:24:45 +02:00
}
@Override
public void hide() {
Gdx.input.setInputProcessor(null);
2014-08-10 17:19:40 +02:00
Gdx.app.log("GameScreen", "hide called");
2014-08-10 00:24:45 +02:00
}
@Override
public void pause() {
2014-08-10 17:19:40 +02:00
Gdx.app.log("GameScreen", "pause called");
2014-08-10 00:24:45 +02:00
}
@Override
public void resume() {
2014-08-10 17:19:40 +02:00
Gdx.app.log("GameScreen", "resume called");
2014-08-10 00:24:45 +02:00
}
@Override
public void dispose() {
2014-08-10 17:19:40 +02:00
Gdx.app.log("GameScreen", "dispose called");
2014-08-10 00:24:45 +02:00
}
@Override
public void doJump() {
2014-08-10 17:19:40 +02:00
Gdx.app.log("GameScreen", "[DO] Jump");
}
@Override
public void switchColor(SwipeDirection sd) {
2014-08-10 17:19:40 +02:00
Gdx.app.log("GameScreen", "[DO] Switch + " + sd.toString());
}
2014-08-10 00:24:45 +02:00
}