From d1d4bcacf238980d5288ca74dc1fd3329ec5ee79 Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 12 May 2021 19:20:37 +0200 Subject: [PATCH] la texture des planets et des fleches en aleatoire --- core/src/sagittarius/model/Arrow.java | 8 +++++++- core/src/sagittarius/model/Planet.java | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/src/sagittarius/model/Arrow.java b/core/src/sagittarius/model/Arrow.java index 6d72e56..1a3d669 100644 --- a/core/src/sagittarius/model/Arrow.java +++ b/core/src/sagittarius/model/Arrow.java @@ -1,6 +1,7 @@ package sagittarius.model; import java.util.ArrayList; +import java.util.Random; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; @@ -49,7 +50,12 @@ public class Arrow extends EntityQuad { this.force = computeForce(); this.landed = false; - Pixmap pm = new Pixmap(new FileHandle("core/assets/arrow1.png")); + Random random = new Random(); + Pixmap pm = new Pixmap(new FileHandle(new String[] { + "core/assets/arrow1.png", + "core/assets/arrow2.png" + }[random.nextInt(2)])); + pm.setBlending(Pixmap.Blending.None); for (int x = 0; x < pm.getWidth(); x++) { for (int y = 0; y < pm.getHeight(); y++) { diff --git a/core/src/sagittarius/model/Planet.java b/core/src/sagittarius/model/Planet.java index 89078a1..c9fa85e 100644 --- a/core/src/sagittarius/model/Planet.java +++ b/core/src/sagittarius/model/Planet.java @@ -1,5 +1,7 @@ package sagittarius.model; +import java.util.Random; + import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; @@ -20,7 +22,14 @@ public class Planet extends EntityCircle { public Planet(Vector2 position, float mass, float radius, Color color) { super(0, mass, color, position, radius); - Pixmap pm = new Pixmap(new FileHandle("core/assets/planet1.png")); + Random random = new Random(); + Pixmap pm = new Pixmap(new FileHandle(new String[] { + "core/assets/planet1.png", + "core/assets/planet2.png", + "core/assets/planet3.png", + "core/assets/planet4.png" + }[random.nextInt(4)])); + pm.setBlending(Pixmap.Blending.None); for (int x = 0; x < pm.getWidth(); x++) { for (int y = 0; y < pm.getHeight(); y++) {