zeugs von armin

This commit is contained in:
Armin Benz 2017-04-14 01:11:39 +02:00
parent c9909f0317
commit c086c74ec6
7 changed files with 47 additions and 10 deletions

View File

@ -1,18 +1,21 @@
package de.samdev.colorrunner;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
import de.samdev.colorrunner.screens.menu.SplashScreen;
public class CRGame extends Game {
public final static boolean DEBUG = true;
@Override
public void create() {
//if (DEBUG)
// setScreen(new GameScreen());
//else
setScreen(new SplashScreen());
setScreen(new SplashScreen());
}
}

View File

@ -17,6 +17,7 @@ public abstract class AbstractGameRenderer {
private final static float FREE_ROAM_WIDTH = 1f/2f;
private int debugTextCount;
private int hudTextCount;
protected OrthographicCamera cam;
protected ShapeRenderer shapeRenderer;
@ -85,15 +86,29 @@ public abstract class AbstractGameRenderer {
debugTextCount = 0;
}
protected void beginHud(){
fontBatch.begin();
font.setColor(1, 0, 1, 1);
hudTextCount = 0;
}
protected void renderDebug(String s) {
Vector3 coords = cam.unproject(new Vector3(10, 10, 0));
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() {
fontBatch.end();
}
protected void endHud(){
fontBatch.end();
}
public abstract void doRender();
}

View File

@ -28,8 +28,9 @@ public class CRGameRenderer extends AbstractGameRenderer {
gameworld.camViewBoundaries = getCamViewRectangle();
if (CRGame.DEBUG) renderDebugInfo();
//renderHud();
renderMain();
if (CRGame.DEBUG) renderDebugBoxes();
}
@ -65,12 +66,13 @@ public class CRGameRenderer extends AbstractGameRenderer {
e.visualRotation, true);
}
spriteBatch.enableBlending();
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.disableBlending();
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 + "\"");
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();
}
}

View File

@ -8,6 +8,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import de.samdev.colorrunner.CRGame;
import de.samdev.colorrunner.game.renderer.AbstractGameRenderer;
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
@ -62,7 +63,7 @@ public class CRGameWorld implements GameInputListener {
if(player.getPosition().y < - 10)
{
((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
((Game) Gdx.app.getApplicationListener()).setScreen(new GameScreen());
}
mapprovider.update(this, player.bounds);

View File

@ -3,10 +3,12 @@ package de.samdev.colorrunner.screens.gameScreen;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import de.samdev.colorrunner.CRGame;
import de.samdev.colorrunner.game.renderer.CRGameRenderer;
import de.samdev.colorrunner.game.world.AverageExecutionLogger;
import de.samdev.colorrunner.game.world.CRGameWorld;
@ -22,7 +24,8 @@ public class GameScreen implements Screen {
public GameScreen() {
world = new CRGameWorld(); // initialize world
renderer = new CRGameRenderer(world, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // initialize renderer
input = new CRGameInputProcessor(world);
}

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
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.utils.ClickListener;
import de.samdev.colorrunner.CRGame;
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
public class MainMenu implements Screen {
private Stage stage = new Stage();
private Table table = new Table();
private CRGame game;
private Skin skin = new Skin(Gdx.files.internal("skins/menuSkin.json"),
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);
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);

View File

@ -9,10 +9,11 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.MathUtils;
import de.samdev.colorrunner.CRGame;
public class SplashScreen implements Screen {
private float loadTime = 0;
private int random = MathUtils.random(5);