More debug utility
[troll.git] / src / main / java / com / codingame / game / View.java
index 13ac93f..29570b6 100644 (file)
@@ -193,6 +193,7 @@ class View {
     Sprite troll;
     Text trollPositionGauge;
     Player p0 = new Player(), p1 = new Player();
     Sprite troll;
     Text trollPositionGauge;
     Player p0 = new Player(), p1 = new Player();
+    Text turnCounter; int _turns = 0;
 
     void init(Model m) {
         model = m;
 
     void init(Model m) {
         model = m;
@@ -218,6 +219,8 @@ class View {
     void startTurn() {
         p0.startTurn();
         p1.startTurn();
     void startTurn() {
         p0.startTurn();
         p1.startTurn();
+
+        animateTurnCounter();
     }
 
     private class Pos {
     }
 
     private class Pos {
@@ -341,6 +344,15 @@ class View {
         trollPositionGauge.setX(troll.getX());
     }
 
         trollPositionGauge.setX(troll.getX());
     }
 
+    void animateTurnCounter() {
+        for (int i = 0; i < 10; i++) {
+            turnCounter.setText("T" + _turns + "." + i);
+            // The following line is likely not a bug.
+            graphicEntityModule.commitEntityState((double) i/9, turnCounter);
+        }
+        _turns++;
+    }
+
     void drawDebug() {
         String[] debugModePngs = graphicEntityModule.createSpriteSheetSplitter()
             .setSourceImage("debug.png")
     void drawDebug() {
         String[] debugModePngs = graphicEntityModule.createSpriteSheetSplitter()
             .setSourceImage("debug.png")
@@ -359,5 +371,18 @@ class View {
             .setAnchorX(0.5)
             .setLoop(true);
         toggleModule.displayOnToggleState(debugMode, "debug", true);
             .setAnchorX(0.5)
             .setLoop(true);
         toggleModule.displayOnToggleState(debugMode, "debug", true);
+
+        turnCounter = graphicEntityModule.createText()
+            .setAnchorX(0.5)
+            .setAnchorY(0)
+            .setX(1920 / 2)
+            .setY(280)
+            .setStrokeColor(0xff0080)
+            .setFillColor(0xff0080)
+            .setFontFamily("monospace")
+            .setFontWeight(Text.FontWeight.BOLD)
+            .setFontSize(100);
+        toggleModule.displayOnToggleState(turnCounter, "debug", true);
+        animateTurnCounter();
     }
 }
     }
 }