From 5189ef95bd2f6c5d1d7be50a4759a2e72ccc2f55 Mon Sep 17 00:00:00 2001 From: GammelJAN Date: Sat, 26 Sep 2020 11:53:03 +0200 Subject: [PATCH] you can see the length of the wall you're drawing --- core/src/com/trs/game/Controller.java | 8 ++++++++ core/src/com/trs/game/model/Model.java | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/core/src/com/trs/game/Controller.java b/core/src/com/trs/game/Controller.java index c26d339..b35ece2 100644 --- a/core/src/com/trs/game/Controller.java +++ b/core/src/com/trs/game/Controller.java @@ -138,6 +138,14 @@ public class Controller extends ApplicationAdapter implements InputProcessor { polygonSpriteBatch.begin(); poly2.draw(polygonSpriteBatch); polygonSpriteBatch.end(); + + renderer.end(); + batch.begin(); + font.setColor(Color.BLACK); + if(model.getCurrentLength()!=0)font.draw(batch, ""+model.getCurrentLength(), Gdx.input.getX()+10, GAME_WORLD_HEIGHT - Gdx.input.getY()+10); + batch.end(); + + renderer.begin(ShapeRenderer.ShapeType.Filled); } // renderer.end(); diff --git a/core/src/com/trs/game/model/Model.java b/core/src/com/trs/game/model/Model.java index 10fb556..3aff92d 100644 --- a/core/src/com/trs/game/model/Model.java +++ b/core/src/com/trs/game/model/Model.java @@ -14,6 +14,7 @@ public class Model { private Polygon tempPolygon; private Vector2 tempStart; private boolean drawing = false; + private int currentLength; private int leftWallLength = 2500; @@ -45,6 +46,7 @@ public class Model { if(drawing){ double angle = StaticMath.calculateAngle(x,y,(int)tempStart.x,(int)tempStart.y); tempPolygon = StaticMath.createPolygon((int)tempStart.x, (int)tempStart.y, angle-Math.PI,10,Vector2.dst(tempStart.x,tempStart.y,x,y)); + currentLength = (int)Vector2.dst(tempStart.x,tempStart.y,x,y); } } public void finishWall(int x, int y){ @@ -77,6 +79,7 @@ public class Model { tempPolygon = null; tempStart = null; drawing = false; + currentLength = 0; } @@ -99,4 +102,8 @@ public class Model { public int getLeftWallLength() { return leftWallLength; } + + public int getCurrentLength() { + return currentLength; + } }