la texture des planets et des fleches en aleatoire

This commit is contained in:
Damien 2021-05-12 19:20:37 +02:00
parent 04a6c0a869
commit d1d4bcacf2
2 changed files with 17 additions and 2 deletions

View file

@ -1,6 +1,7 @@
package sagittarius.model; package sagittarius.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
@ -49,7 +50,12 @@ public class Arrow extends EntityQuad {
this.force = computeForce(); this.force = computeForce();
this.landed = false; 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); pm.setBlending(Pixmap.Blending.None);
for (int x = 0; x < pm.getWidth(); x++) { for (int x = 0; x < pm.getWidth(); x++) {
for (int y = 0; y < pm.getHeight(); y++) { for (int y = 0; y < pm.getHeight(); y++) {

View file

@ -1,5 +1,7 @@
package sagittarius.model; package sagittarius.model;
import java.util.Random;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap; 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) { public Planet(Vector2 position, float mass, float radius, Color color) {
super(0, mass, color, position, radius); 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); pm.setBlending(Pixmap.Blending.None);
for (int x = 0; x < pm.getWidth(); x++) { for (int x = 0; x < pm.getWidth(); x++) {
for (int y = 0; y < pm.getHeight(); y++) { for (int y = 0; y < pm.getHeight(); y++) {