diff --git a/core/src/sagittarius/SagittariusGame.java b/core/src/sagittarius/SagittariusGame.java index 466eba6..1c8195b 100644 --- a/core/src/sagittarius/SagittariusGame.java +++ b/core/src/sagittarius/SagittariusGame.java @@ -4,6 +4,8 @@ import com.badlogic.gdx.Game; import com.kotcrab.vis.ui.VisUI; import sagittarius.view.BaseScreen; +import sagittarius.view.GameScreen; +import sagittarius.view.SettingsScreen; import sagittarius.view.StartScreen; public class SagittariusGame extends Game { @@ -29,7 +31,7 @@ public class SagittariusGame extends Game { @Override public void create() { VisUI.load(); - game.setScreen(new StartScreen()); + game.setScreen(new GameScreen()); } } diff --git a/core/src/sagittarius/model/EntityCircle.java b/core/src/sagittarius/model/EntityCircle.java index 5f64f9f..183ddf1 100644 --- a/core/src/sagittarius/model/EntityCircle.java +++ b/core/src/sagittarius/model/EntityCircle.java @@ -46,13 +46,13 @@ public abstract class EntityCircle extends Entity { @Override protected float[] getHitbox() { // peut ĂȘtre optimisĂ© - int segments = 128; + int segments = 64; float[] vertices = new float[2*segments]; float theta = 360.0f / segments; for (int i = 0; i < segments; i++) { - vertices[2*i] = getX() + MathUtils.cosDeg(theta * (i+1))*radius; - vertices[2*i+1] = getY() + MathUtils.sinDeg(theta * (i+1))*radius; + vertices[2*i] = getX() + MathUtils.cosDeg(theta * (i+1) + getRotation())*radius; + vertices[2*i+1] = getY() + MathUtils.sinDeg(theta * (i+1) + getRotation())*radius; } return vertices; diff --git a/core/src/sagittarius/model/Moon.java b/core/src/sagittarius/model/Moon.java index a422698..c0257db 100644 --- a/core/src/sagittarius/model/Moon.java +++ b/core/src/sagittarius/model/Moon.java @@ -14,6 +14,7 @@ public class Moon extends Planet { public Moon(Planet sun, float mass, float radius, float altitude, Color color) { super(new Vector2(), mass, radius, color); + this.angle = MathUtils.random(360); this.sun = sun; this.altitude = altitude; } @@ -31,9 +32,9 @@ public class Moon extends Planet { @Override public void act(float dt) { - this.rotateBy(10.0f / this.altitude); - this.setX(sun.getX() + this.altitude*MathUtils.cosDeg(this.getRotation())); - this.setY(sun.getY() + this.altitude*MathUtils.sinDeg(this.getRotation())); + this.angle += 10.0f / this.altitude; + this.setX(sun.getX() + this.altitude*MathUtils.cosDeg(this.angle)); + this.setY(sun.getY() + this.altitude*MathUtils.sinDeg(this.angle)); super.act(dt); } diff --git a/core/src/sagittarius/model/Planet.java b/core/src/sagittarius/model/Planet.java index b15b859..ced8438 100644 --- a/core/src/sagittarius/model/Planet.java +++ b/core/src/sagittarius/model/Planet.java @@ -1,10 +1,15 @@ package sagittarius.model; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; public class Planet extends EntityCircle { +// ---------- ATTRIBUTEs ---------- + + float revolutionRate = MathUtils.randomTriangular(1) + 1; + // ---------- CONSTRUCTORs ---------- public Planet(Vector2 position, float mass, float radius, Color color) { @@ -13,6 +18,12 @@ public class Planet extends EntityCircle { // ---------- METHODs ---------- + @Override + public void act(float dt) { + super.act(dt); + this.rotateBy(revolutionRate / this.radius); + } + @Override protected String getInfo() { return diff --git a/core/src/sagittarius/model/Player.java b/core/src/sagittarius/model/Player.java index 3abe8a8..263e6b0 100644 --- a/core/src/sagittarius/model/Player.java +++ b/core/src/sagittarius/model/Player.java @@ -17,7 +17,7 @@ public class Player extends EntityQuad { public Player(Planet home, Color color) { super(MathUtils.random(360), 0, color, home.getPosition()); - this.setRotation(angle-90); + this.setRotation(home.getRotation() + angle - 90); this.setSize(50, 100); this.setOrigin(getWidth()/2, getHeight()/2); @@ -47,10 +47,10 @@ public class Player extends EntityQuad { } } - setX(home.getX() + (home.getRadius() + getHeight()/2)*MathUtils.cosDeg(angle)); - setY(home.getY() + (home.getRadius() + getHeight()/2)*MathUtils.sinDeg(angle)); + setX(home.getX() + (home.getRadius() + getHeight()/2)*MathUtils.cosDeg(home.getRotation() + angle)); + setY(home.getY() + (home.getRadius() + getHeight()/2)*MathUtils.sinDeg(home.getRotation() + angle)); - this.setRotation(angle-90); + this.setRotation(home.getRotation() + angle - 90); } @Override diff --git a/core/src/sagittarius/view/GameScreen.java b/core/src/sagittarius/view/GameScreen.java index 7b3cace..f657452 100644 --- a/core/src/sagittarius/view/GameScreen.java +++ b/core/src/sagittarius/view/GameScreen.java @@ -37,15 +37,18 @@ public class GameScreen extends BaseScreen { // planets & moons attractors = new Group(); - Planet planet1 = new Planet(new Vector2(400, 400), 1000, 50, Color.BLUE); + Planet planet1 = new Planet(new Vector2(300, 200), 1000, 50, Color.BLUE); attractors.addActor(planet1); - Planet planet2 = new Planet(new Vector2(1400, 700), 1000, 100, Color.ORANGE); + Planet planet2 = new Planet(new Vector2(1200, 700), 4000, 200, Color.ORANGE); attractors.addActor(planet2); - Moon moon2_1 = new Moon(planet2, 100, 10, 300, Color.MAGENTA); + Moon moon2_1 = new Moon(planet2, 100, 70, 500, Color.MAGENTA); attractors.addActor(moon2_1); + Planet planet3 = new Planet(new Vector2(1500, 100), 1000, 70, Color.PINK); + attractors.addActor(planet3); + mainStage.addActor(attractors); // players @@ -57,6 +60,9 @@ public class GameScreen extends BaseScreen { Player player2 = new Player(planet2, Color.WHITE); players.addActor(player2); + Player player3 = new Player(moon2_1, Color.YELLOW); + players.addActor(player3); + mainStage.addActor(players); // arrows