zeugs von armin
This commit is contained in:
parent
c9909f0317
commit
c086c74ec6
|
@ -1,18 +1,21 @@
|
||||||
package de.samdev.colorrunner;
|
package de.samdev.colorrunner;
|
||||||
|
|
||||||
import com.badlogic.gdx.Game;
|
import com.badlogic.gdx.Game;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
|
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
|
||||||
import de.samdev.colorrunner.screens.menu.SplashScreen;
|
import de.samdev.colorrunner.screens.menu.SplashScreen;
|
||||||
|
|
||||||
public class CRGame extends Game {
|
public class CRGame extends Game {
|
||||||
public final static boolean DEBUG = true;
|
public final static boolean DEBUG = true;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
//if (DEBUG)
|
//if (DEBUG)
|
||||||
// setScreen(new GameScreen());
|
// setScreen(new GameScreen());
|
||||||
//else
|
//else
|
||||||
setScreen(new SplashScreen());
|
|
||||||
|
setScreen(new SplashScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ public abstract class AbstractGameRenderer {
|
||||||
private final static float FREE_ROAM_WIDTH = 1f/2f;
|
private final static float FREE_ROAM_WIDTH = 1f/2f;
|
||||||
|
|
||||||
private int debugTextCount;
|
private int debugTextCount;
|
||||||
|
private int hudTextCount;
|
||||||
|
|
||||||
protected OrthographicCamera cam;
|
protected OrthographicCamera cam;
|
||||||
protected ShapeRenderer shapeRenderer;
|
protected ShapeRenderer shapeRenderer;
|
||||||
|
@ -85,15 +86,29 @@ public abstract class AbstractGameRenderer {
|
||||||
|
|
||||||
debugTextCount = 0;
|
debugTextCount = 0;
|
||||||
}
|
}
|
||||||
|
protected void beginHud(){
|
||||||
|
fontBatch.begin();
|
||||||
|
font.setColor(1, 0, 1, 1);
|
||||||
|
|
||||||
|
hudTextCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected void renderDebug(String s) {
|
protected void renderDebug(String s) {
|
||||||
Vector3 coords = cam.unproject(new Vector3(10, 10, 0));
|
Vector3 coords = cam.unproject(new Vector3(10, 10, 0));
|
||||||
font.draw(fontBatch, s, coords.x, coords.y - debugTextCount++ * 20);
|
font.draw(fontBatch, s, coords.x, coords.y - debugTextCount++ * 20);
|
||||||
}
|
}
|
||||||
|
protected void renderHud(String s){
|
||||||
|
Vector3 coords = cam.unproject(new Vector3(10, 10, 0));
|
||||||
|
font.draw(fontBatch, s, coords.x + hudTextCount++ * 20, coords.y);
|
||||||
|
}
|
||||||
|
|
||||||
protected void endDebug() {
|
protected void endDebug() {
|
||||||
fontBatch.end();
|
fontBatch.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void endHud(){
|
||||||
|
fontBatch.end();
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void doRender();
|
public abstract void doRender();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,9 @@ public class CRGameRenderer extends AbstractGameRenderer {
|
||||||
gameworld.camViewBoundaries = getCamViewRectangle();
|
gameworld.camViewBoundaries = getCamViewRectangle();
|
||||||
|
|
||||||
if (CRGame.DEBUG) renderDebugInfo();
|
if (CRGame.DEBUG) renderDebugInfo();
|
||||||
|
//renderHud();
|
||||||
renderMain();
|
renderMain();
|
||||||
|
|
||||||
|
|
||||||
if (CRGame.DEBUG) renderDebugBoxes();
|
if (CRGame.DEBUG) renderDebugBoxes();
|
||||||
}
|
}
|
||||||
|
@ -65,12 +66,13 @@ public class CRGameRenderer extends AbstractGameRenderer {
|
||||||
e.visualRotation, true);
|
e.visualRotation, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
spriteBatch.enableBlending();
|
spriteBatch.enableBlending();
|
||||||
Vector3 cw_coords = cam.unproject(new Vector3(Gdx.graphics.getWidth(), 0, 0));
|
Vector3 cw_coords = cam.unproject(new Vector3(Gdx.graphics.getWidth(), 0, 0));
|
||||||
spriteBatch.draw(CRAssets.TEX_COLORWHEEL, cw_coords.x - 70, cw_coords.y - 70, 64, 64);
|
spriteBatch.draw(CRAssets.TEX_COLORWHEEL, cw_coords.x - 70, cw_coords.y - 70, 64, 64);
|
||||||
spriteBatch.disableBlending();
|
spriteBatch.disableBlending();
|
||||||
|
|
||||||
spriteBatch.end();
|
spriteBatch.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,4 +86,12 @@ public class CRGameRenderer extends AbstractGameRenderer {
|
||||||
if (gameworld.mapprovider instanceof EndlessMapProvider)renderDebug("Procedural Piece: \"" + ((EndlessMapProvider)gameworld.mapprovider).getCurrentSection(gameworld.player.bounds).piece_name + "\"");
|
if (gameworld.mapprovider instanceof EndlessMapProvider)renderDebug("Procedural Piece: \"" + ((EndlessMapProvider)gameworld.mapprovider).getCurrentSection(gameworld.player.bounds).piece_name + "\"");
|
||||||
endDebug();
|
endDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void renderHud(){
|
||||||
|
beginHud();
|
||||||
|
renderHud("Test");
|
||||||
|
renderHud("TEst2");
|
||||||
|
if (gameworld.mapprovider instanceof EndlessMapProvider)renderDebug("Procedural Piece: \"" + ((EndlessMapProvider)gameworld.mapprovider).getCurrentSection(gameworld.player.bounds).piece_name + "\"");
|
||||||
|
endHud();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
|
import de.samdev.colorrunner.CRGame;
|
||||||
import de.samdev.colorrunner.game.renderer.AbstractGameRenderer;
|
import de.samdev.colorrunner.game.renderer.AbstractGameRenderer;
|
||||||
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
|
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
|
||||||
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
|
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
|
||||||
|
@ -62,7 +63,7 @@ public class CRGameWorld implements GameInputListener {
|
||||||
|
|
||||||
if(player.getPosition().y < - 10)
|
if(player.getPosition().y < - 10)
|
||||||
{
|
{
|
||||||
((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
|
((Game) Gdx.app.getApplicationListener()).setScreen(new GameScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
mapprovider.update(this, player.bounds);
|
mapprovider.update(this, player.bounds);
|
||||||
|
|
|
@ -3,10 +3,12 @@ package de.samdev.colorrunner.screens.gameScreen;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.InputMultiplexer;
|
import com.badlogic.gdx.InputMultiplexer;
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.input.GestureDetector;
|
import com.badlogic.gdx.input.GestureDetector;
|
||||||
import com.badlogic.gdx.maps.tiled.TiledMap;
|
import com.badlogic.gdx.maps.tiled.TiledMap;
|
||||||
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
|
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
|
||||||
|
|
||||||
|
import de.samdev.colorrunner.CRGame;
|
||||||
import de.samdev.colorrunner.game.renderer.CRGameRenderer;
|
import de.samdev.colorrunner.game.renderer.CRGameRenderer;
|
||||||
import de.samdev.colorrunner.game.world.AverageExecutionLogger;
|
import de.samdev.colorrunner.game.world.AverageExecutionLogger;
|
||||||
import de.samdev.colorrunner.game.world.CRGameWorld;
|
import de.samdev.colorrunner.game.world.CRGameWorld;
|
||||||
|
@ -22,7 +24,8 @@ public class GameScreen implements Screen {
|
||||||
public GameScreen() {
|
public GameScreen() {
|
||||||
world = new CRGameWorld(); // initialize world
|
world = new CRGameWorld(); // initialize world
|
||||||
renderer = new CRGameRenderer(world, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // initialize renderer
|
renderer = new CRGameRenderer(world, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // initialize renderer
|
||||||
|
|
||||||
|
|
||||||
input = new CRGameInputProcessor(world);
|
input = new CRGameInputProcessor(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.Game;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
|
@ -13,13 +14,15 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
|
|
||||||
|
import de.samdev.colorrunner.CRGame;
|
||||||
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
|
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
|
||||||
|
|
||||||
public class MainMenu implements Screen {
|
public class MainMenu implements Screen {
|
||||||
|
|
||||||
private Stage stage = new Stage();
|
private Stage stage = new Stage();
|
||||||
private Table table = new Table();
|
private Table table = new Table();
|
||||||
|
private CRGame game;
|
||||||
|
|
||||||
private Skin skin = new Skin(Gdx.files.internal("skins/menuSkin.json"),
|
private Skin skin = new Skin(Gdx.files.internal("skins/menuSkin.json"),
|
||||||
new TextureAtlas(Gdx.files.internal("skins/menuSkin.pack")));
|
new TextureAtlas(Gdx.files.internal("skins/menuSkin.pack")));
|
||||||
|
|
||||||
|
@ -30,7 +33,8 @@ public class MainMenu implements Screen {
|
||||||
|
|
||||||
private Label title = new Label("Color Runner", skin);
|
private Label title = new Label("Color Runner", skin);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||||
|
|
|
@ -9,10 +9,11 @@ import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
|
import de.samdev.colorrunner.CRGame;
|
||||||
|
|
||||||
|
|
||||||
public class SplashScreen implements Screen {
|
public class SplashScreen implements Screen {
|
||||||
|
|
||||||
private float loadTime = 0;
|
private float loadTime = 0;
|
||||||
|
|
||||||
private int random = MathUtils.random(5);
|
private int random = MathUtils.random(5);
|
||||||
|
|
Loading…
Reference in New Issue