- private void drawBackground() {
- graphicEntityModule.createSprite()
- .setImage("background.png")
- .setAnchor(0);
- }
-
- private void drawPlayer() {
- for (Player player : gameManager.getPlayers()) {
- boolean p0 = player.getIndex() == 0;
- int x = p0 ? 280 : 1920 - 280;
- int y = 220;
-
- Rectangle border1 = graphicEntityModule
- .createRectangle()
- .setWidth(140)
- .setHeight(140)
- .setX(x - 70)
- .setY(y - 70)
- .setLineWidth(0)
- .setFillColor(player.getColorToken());
-
- Rectangle border2 = graphicEntityModule
- .createRectangle()
- .setWidth(120)
- .setHeight(120)
- .setX(x - 60)
- .setY(y - 60)
- .setLineWidth(0)
- .setFillColor(0xffffff);
-
- Sprite avatarSprite = graphicEntityModule.createSprite()
- .setX(x)
- .setY(y)
- .setZIndex(20)
- .setImage(player.getAvatarToken())
- .setAnchor(0.5)
- .setBaseHeight(116)
- .setBaseWidth(116);
-
- player.avatar = graphicEntityModule.createGroup(border1, border2, avatarSprite);
-
- Text text = graphicEntityModule.createText(player.getNicknameToken())
- .setX(x)
- .setY(y + 120)
- .setZIndex(20)
- .setFontSize(40)
- .setFillColor(0x7f3f00)
- .setAnchor(0.5);
-
- player.stoneCounter = graphicEntityModule.createText("S")
- .setX(x)
- .setY(y+200)
- .setZIndex(20)
- .setFontSize(40)
- .setFillColor(0x7f3f00)
- .setAnchor(0.5);
-
- player.message = graphicEntityModule.createText()
- .setX(p0 ? 15 : 1920-15)
- .setY(680)
- .setZIndex(1)
- .setFontSize(40)
- .setStrokeColor(0x000000)
- .setFillColor(0xffbf7f)
- .setAnchorX(p0 ? 0 : 1)
- .setAnchorY(1);
-
- player.castle = graphicEntityModule.createSprite()
- .setImage("castle.png")
- .setTint(player.getColorToken())
- .setX(p0 ? 160 : 1920-160)
- .setY(p0 ? 890 : 880)
- .setZIndex(1)
- .setAnchorX(0.5)
- .setAnchorY(1)
- .setScaleX(p0 ? 1 : -1);
-
- player.stone = graphicEntityModule.createText()
- .setZIndex(3)
- .setFontSize(150)
- .setFillColor(0x12322a)
- .setAnchor(0.5)
- .setAlpha(0);
- }
- }
-
- private void drawTroll() {
- view.troll = graphicEntityModule.createSprite()
- .setImage("troll.png")
- .setAnchorX(0.5)
- .setAnchorY(1)
- .setX(1920/2)
- .setY(880)
- .setZIndex(2);
- view.trollPositionGauge = graphicEntityModule.createText()
- .setZIndex(2)
- .setAnchor(0.5)
- .setFontSize(40)
- .setX(1980/2)
- .setY(980)
- .setFillColor(0xffffff);
- }
-
- private void moveTroll() {
- graphicEntityModule.commitEntityState(0.5, view.troll, view.trollPositionGauge);
- int x0 = p0.castle.getX(), x1 = p1.castle.getX();
- int y0 = p0.castle.getY(), y1 = p1.castle.getY();
- view.troll.setX(x0 + model.trollPosition * (x1-x0) / model.roadLength,
- Curve.ELASTIC);
- view.troll.setY(y0 + model.trollPosition * (y1-y0) / model.roadLength,
- Curve.ELASTIC);
-
- view.trollPositionGauge.setX((view.trollPositionGauge.getX() + view.troll.getX()) / 2);
- int delta = model.trollPosition - model.roadLength / 2;
- if (delta < 0) {
- view.trollPositionGauge.setText("← " + Math.abs(delta));
- }
- else if (delta > 0) {
- view.trollPositionGauge.setText(Math.abs(delta) + " →");
- }
- else {
- view.trollPositionGauge.setText("↔");
- }
- graphicEntityModule.commitEntityState(0.75, view.trollPositionGauge);
- view.trollPositionGauge.setX(view.troll.getX());