diff options
Diffstat (limited to 'test/src/ch')
5 files changed, 53 insertions, 27 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java index d65c853..deb8dca 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java @@ -30,7 +30,7 @@ public abstract class AbstractScreen implements Screen protected final Vector3 boardTouch = new Vector3(); protected final Vector3 hudTouch = new Vector3(); - private ShapeRenderer debugShapes = null; + private ShapeRenderer shapeRenderer = null; protected final String dom; protected final GdxBoardTest app; @@ -55,18 +55,21 @@ public abstract class AbstractScreen implements Screen this.inputDelay = 0f; this.paused = false; - if (DEBUG) this.debugShapes = new ShapeRenderer(); + if (DEBUG) this.shapeRenderer = new ShapeRenderer(); HdpiUtils.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } - protected void drawDebug(ShapeRenderer shapeRenderer) { } + protected abstract boolean animate(float delta); protected abstract void draw(SpriteBatch batch); + protected abstract void drawDebug(ShapeRenderer shapeRenderer); @Override public void render(float delta) { if (paused) return; - Gdx.gl.glClearColor(1, 1, 1, 1); + if (!animate(delta)) return; + + Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); @@ -77,11 +80,11 @@ public abstract class AbstractScreen implements Screen if (DEBUG) { Gdx.gl.glEnable(GL20.GL_BLEND); - debugShapes.setAutoShapeType(true); - debugShapes.setProjectionMatrix(camera.combined); - debugShapes.begin(); - drawDebug(debugShapes); - debugShapes.end(); + shapeRenderer.setAutoShapeType(true); + shapeRenderer.setProjectionMatrix(camera.combined); + shapeRenderer.begin(); + drawDebug(shapeRenderer); + shapeRenderer.end(); } } diff --git a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java index 19602ee..6fcc30f 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java @@ -3,6 +3,7 @@ package ch.asynk.gdx.boardgame.test; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.math.Vector2; @@ -164,11 +165,8 @@ public class AnimationsScreen extends AbstractScreen super.dispose(); } - @Override public void draw(SpriteBatch batch) { } - @Override public void render(float delta) + @Override protected boolean animate(float delta) { - if (paused) return; - if (inputBlocked) { inputDelay -= delta; if (inputDelay <= 0f) @@ -178,15 +176,13 @@ public class AnimationsScreen extends AbstractScreen dice.animate(delta); if (animations.animate(delta)) { app.switchToMenu(); - return; + return false; } + return true; + } - Gdx.gl.glClearColor(0, 0, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - - cam.applyBoardViewport(); - batch.setProjectionMatrix(cam.combined); - batch.begin(); + @Override public void draw(SpriteBatch batch) + { batch.draw(map, 0, 0); for (int i = 0; i < path.size(); i++) { path.get(i).draw(batch); @@ -197,7 +193,19 @@ public class AnimationsScreen extends AbstractScreen other2.draw(batch); dice.draw(batch); animations.draw(batch); - batch.end(); + } + + @Override public void drawDebug(ShapeRenderer shapeRenderer) + { + for (int i = 0; i < path.size(); i++) { + path.get(i).drawDebug(shapeRenderer); + } + panzer.drawDebug(shapeRenderer); + other0.drawDebug(shapeRenderer); + other1.drawDebug(shapeRenderer); + other2.drawDebug(shapeRenderer); + dice.drawDebug(shapeRenderer); + animations.drawDebug(shapeRenderer); } @Override public void resize(int width, int height) diff --git a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java index 85b57c9..5357449 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java @@ -3,6 +3,7 @@ package ch.asynk.gdx.boardgame.test; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.math.Vector2; @@ -170,19 +171,19 @@ public class BoardScreen extends AbstractScreen setState(State.HEX_V); } - @Override public void draw(SpriteBatch batch) { } - @Override public void render(float delta) + @Override protected boolean animate(float delta) { - if (paused) return; - if (inputBlocked) { inputDelay -= delta; if (inputDelay <= 0f) inputBlocked = false; } + return true; + } - Gdx.gl.glClearColor(0, 0, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + @Override public void draw(SpriteBatch batch) + { + batch.end(); // for AbstractScreen cam.applyBoardViewport(); batch.setProjectionMatrix(cam.combined); @@ -195,8 +196,12 @@ public class BoardScreen extends AbstractScreen batch.begin(); root.draw(batch); batch.end(); + + batch.begin(); // for AbstractScreen } + @Override public void drawDebug(ShapeRenderer shapeRenderer) { } + @Override public void resize(int width, int height) { GdxBoardTest.debug("BoardScrean", String.format("resize (%d,%d)",width, height)); diff --git a/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java b/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java index 95dbd80..3c198e0 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java @@ -3,6 +3,7 @@ package ch.asynk.gdx.boardgame.test; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ch.asynk.gdx.boardgame.ui.Alignment; import ch.asynk.gdx.boardgame.ui.Menu; @@ -34,6 +35,8 @@ public class MenuScreen extends AbstractScreen this.camera.position.set(bg.getWidth() / 2f, bg.getHeight() / 2f, 0); } + @Override protected boolean animate(float delta) { return true; } + @Override protected void draw(SpriteBatch batch) { batch.draw(bg, 0, 0); @@ -41,6 +44,11 @@ public class MenuScreen extends AbstractScreen root.draw(batch); } + @Override protected void drawDebug(ShapeRenderer shapeRenderer) + { + root.drawDebug(shapeRenderer); + } + private void drawCorners(SpriteBatch batch) { float right = root.getInnerX() + root.getInnerWidth() - corner.getWidth(); diff --git a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java index 8793510..14d282c 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java @@ -94,6 +94,8 @@ public class UiScreen extends AbstractScreen this.state = state; } + @Override protected boolean animate(float delta) { return true; } + @Override protected void draw(SpriteBatch batch) { batch.draw(bg, 0, 0); |