X-Git-Url: https://troll.desast.re/troll.git/blobdiff_plain/bea135ec39ff862fb25b4f99e8c7d48eb44134f2..1b2f76237b137aedd6c447580412a3b93d50a9bf:/src/main/java/com/codingame/game/View.java?ds=sidebyside diff --git a/src/main/java/com/codingame/game/View.java b/src/main/java/com/codingame/game/View.java index 8653ab4..d3d51d1 100644 --- a/src/main/java/com/codingame/game/View.java +++ b/src/main/java/com/codingame/game/View.java @@ -1,6 +1,8 @@ package com.codingame.game; import java.util.Random; +import java.util.ArrayList; +import java.util.Comparator; import com.codingame.gameengine.core.MultiplayerGameManager; import com.codingame.gameengine.module.entities.GraphicEntityModule; @@ -213,12 +215,18 @@ class View { p1.startTurn(); } + private class Pos { + int x, y; + Pos(int _x, int _y) { x = _x; y = _y; } + } + private void drawBackground() { graphicEntityModule.createSprite() .setImage("background.png") .setAnchor(0); - int numTrees = random.nextInt(101); + int numTrees = random.nextInt(21); + ArrayList poss = new ArrayList(numTrees); while (numTrees --> 0) { int x, y; do { @@ -226,16 +234,25 @@ class View { // yes, this biases randomness wrt perspective! :-( y = 700 + random.nextInt(175); } while (y > 880 && (x < 200 || x > 1720)); - double scale = ( 100.0 / 433.0 // base height from PNG - * (y - 680) / (875 - 680) ); // perspective + poss.add(new Pos(x, y)); + } + poss.sort(new Comparator() { + public int compare(Pos a, Pos b) { return a.y < b.y ? -1 : 1; } + }); + + for (Pos p : poss) { + double scale = ( 90.0 / 433.0 // base height from PNG + * (p.y - 680) / (875 - 680) ); // perspective graphicEntityModule.createSprite() - .setImage("Alshock.png") + .setImage(random.nextInt(2) == 0 ? "Alshockv1.png" + : "Alshockv2.png") .setAnchorX(0.5) .setAnchorY(1) - .setX(x) - .setY(y) - .setScaleX(scale * (random.nextInt(2) == 0 ? -1 : 1)) - .setScaleY(scale) + .setX(p.x) + .setY(p.y) + .setScaleX(scale * (random.nextInt(2) == 0 ? -1 : 1) + * (1 + (random.nextDouble() - 0.5) / 6)) + .setScaleY(scale * (1 + (random.nextDouble() -0.5) / 6)) .setRotation((random.nextDouble() - 0.5) * Math.PI / 1800) .setSkewX((random.nextDouble() - 0.5) /4) .setSkewY((random.nextDouble() - 0.5) /8);