38dcac1b59bcb93c93865a19b6eee1f7132c985f
[troll.git] / src / main / java / com / codingame / game / View.java
1 package com.codingame.game;
2
3 import java.util.Random;
4
5 import com.codingame.gameengine.module.entities.GraphicEntityModule;
6 import com.codingame.gameengine.module.entities.Sprite;
7 import com.codingame.gameengine.module.entities.Text;
8 import com.google.inject.Inject;
9
10 class View {
11     @Inject private GraphicEntityModule graphicEntityModule;
12
13     Random random = new Random();
14     Sprite troll;
15     Text trollPositionGauge;
16
17     void init() {
18         drawBackground();
19         drawTroll();
20     }
21
22     private void drawBackground() {
23         graphicEntityModule.createSprite()
24                 .setImage("background.png")
25                 .setAnchor(0);
26     }
27
28     private void drawTroll() {
29         troll = graphicEntityModule.createSprite()
30             .setImage("troll.png")
31             .setAnchorX(0.5)
32             .setAnchorY(1)
33             .setX(1920/2)
34             .setY(880)
35             .setZIndex(2);
36         trollPositionGauge = graphicEntityModule.createText()
37             .setZIndex(2)
38             .setAnchor(0.5)
39             .setFontSize(40)
40             .setX(1980/2)
41             .setY(980)
42             .setFillColor(0xffffff);
43     }
44
45 }