color fix

This commit is contained in:
Damien 2021-05-29 12:41:40 +02:00
parent 9492b79f38
commit 2406453507
2 changed files with 15 additions and 12 deletions

View file

@ -11,6 +11,7 @@ public class SagittariusGame extends Game {
// Constants
public static float G = 100;
public static int numberPlayers = 3;
public static boolean debugMode = false;
public static Music music;
public static boolean disableMusic = true;

View file

@ -86,6 +86,7 @@ public class GameScreen extends BaseScreen implements InputProcessor {
attractors = new Group();
for (int i = 0; i < numberPlanets; i++) {
// Position of the new planet
Vector2 position;
if (i == 0) {
position = new Vector2(0, 0);
@ -111,19 +112,24 @@ public class GameScreen extends BaseScreen implements InputProcessor {
}
} while (shortestDistance < minDistance);
}
// other attributs
int mass = minMass + MathUtils.random(maxMass - minMass);
int radius = minRadius + MathUtils.random(maxRadius - minRadius);
Color color = new Color((int)(Math.random() * 0x1000000));
Color color = new Color((float) Math.random(), (float) Math.random(), (float) Math.random(), 1);
// create the planet
Planet planet = new Planet(position, mass, radius, color);
attractors.addActor(planet);
}
// create a moon
Moon moon = new Moon(
(Planet) attractors.getChild( MathUtils.random(numberPlanets-1)),
minMass / 2 + MathUtils.random(maxMass - minMass) / 2,
minRadius / 2 + MathUtils.random(maxRadius - minRadius) / 2,
minDistance / 2,
new Color((int)(Math.random() * 0x1000000))
new Color((float) Math.random(), (float) Math.random(), (float) Math.random(), 1)
);
attractors.addActor(moon);
@ -132,14 +138,10 @@ public class GameScreen extends BaseScreen implements InputProcessor {
// players
players = new Group();
Player player1 = new Player((Planet) attractors.getChild(0), Color.RED);
players.addActor(player1);
Player player2 = new Player((Planet) attractors.getChild(1), Color.WHITE);
players.addActor(player2);
Player player3 = new Player((Planet) attractors.getChild(2), Color.YELLOW);
players.addActor(player3);
for (int i = 0; i < SagittariusGame.numberPlayers; i++) {
Player player = new Player((Planet) attractors.getChild(i), new Color((float) Math.random(), (float) Math.random(), (float) Math.random(), 1));
players.addActor(player);
}
mainStage.addActor(players);
@ -155,8 +157,8 @@ public class GameScreen extends BaseScreen implements InputProcessor {
// game turns
playerIndex = 0;
player1.setActive(true);
playerCurrent = player1;
((Player) players.getChild(0)).setActive(true);
playerCurrent = (Player) players.getChild(0);
// camera stuff
mainCameraPosition = mainStage.getCamera().position;