Split some code to view
[troll.git] / src / main / java / com / codingame / game / View.java
index 34894ac..38dcac1 100644 (file)
@@ -2,11 +2,44 @@ package com.codingame.game;
 
 import java.util.Random;
 
+import com.codingame.gameengine.module.entities.GraphicEntityModule;
 import com.codingame.gameengine.module.entities.Sprite;
 import com.codingame.gameengine.module.entities.Text;
+import com.google.inject.Inject;
 
 class View {
+    @Inject private GraphicEntityModule graphicEntityModule;
+
     Random random = new Random();
     Sprite troll;
     Text trollPositionGauge;
+
+    void init() {
+        drawBackground();
+        drawTroll();
+    }
+
+    private void drawBackground() {
+        graphicEntityModule.createSprite()
+                .setImage("background.png")
+                .setAnchor(0);
+    }
+
+    private void drawTroll() {
+        troll = graphicEntityModule.createSprite()
+            .setImage("troll.png")
+            .setAnchorX(0.5)
+            .setAnchorY(1)
+            .setX(1920/2)
+            .setY(880)
+            .setZIndex(2);
+        trollPositionGauge = graphicEntityModule.createText()
+            .setZIndex(2)
+            .setAnchor(0.5)
+            .setFontSize(40)
+            .setX(1980/2)
+            .setY(980)
+            .setFillColor(0xffffff);
+    }
+
 }