- random = new Random(gameManager.getSeed());
- switch (random.nextInt(4)) {
- case 0:
- roadLength = 7;
- initialStones = 15;
- break;
- case 1:
- roadLength = 7;
- initialStones = 30;
- break;
- case 2:
- roadLength = 15;
- initialStones = 30;
- break;
- case 3:
- roadLength = 15;
- initialStones = 50;
- break;
- }
-
- trollPosition = (roadLength - 1) / 2;
-
- p0 = gameManager.getPlayer(0);
- p0.setCastlePosition(0);
- p0.setMultiplier(1);
- p0.adjustScore(trollPosition);
- p0.sendInputLine(String.format("%d %d", roadLength - 1, initialStones));
-
- p1 = gameManager.getPlayer(1);
- p1.setCastlePosition(roadLength-1);
- p1.setMultiplier(-1);
- p1.adjustScore(trollPosition);
- p1.sendInputLine(String.format("%d %d", roadLength - 1, initialStones));
-
- drawBackground();
- drawPlayer();
- drawTroll();
-
- // result in text display, so do last:
- p0.setStones(initialStones);
- p1.setStones(initialStones);
-
- gameManager.setFrameDuration(2000);
- }
-
- 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);