2021-04-08 19:34:17 +00:00
|
|
|
package sagittarius.view;
|
2021-04-05 16:45:57 +00:00
|
|
|
|
2021-04-09 13:03:24 +00:00
|
|
|
import com.badlogic.gdx.Gdx;
|
2021-04-05 16:45:57 +00:00
|
|
|
import com.badlogic.gdx.graphics.Color;
|
2021-04-09 09:57:52 +00:00
|
|
|
import com.badlogic.gdx.math.Vector2;
|
2021-04-09 13:03:24 +00:00
|
|
|
import com.badlogic.gdx.math.Vector3;
|
2021-04-09 13:49:33 +00:00
|
|
|
import com.badlogic.gdx.scenes.scene2d.Group;
|
2021-04-05 16:45:57 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
import sagittarius.model.*;
|
2021-04-05 16:45:57 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
public class GameScreen extends BaseScreen {
|
2021-04-05 16:45:57 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
// ---------- ATTRIBUTEs ----------
|
2021-04-05 16:45:57 +00:00
|
|
|
|
2021-04-09 13:03:24 +00:00
|
|
|
// Cursors
|
|
|
|
public static Vector2 screenCursor;
|
|
|
|
private static Vector3 unprojectedCursor;
|
|
|
|
public static Vector2 worldCursor;
|
|
|
|
|
2021-04-09 14:28:37 +00:00
|
|
|
// planets = attractors for arrows
|
|
|
|
public static Group planets; // TODO: move this in SagittariusGame ?
|
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
// ---------- METHODs ----------
|
2021-04-05 16:45:57 +00:00
|
|
|
|
|
|
|
@Override
|
2021-04-09 09:57:52 +00:00
|
|
|
public void initialize() {
|
|
|
|
|
2021-04-09 13:03:24 +00:00
|
|
|
mainStage.setDebugAll(true); // TODO: disable later
|
|
|
|
|
2021-04-09 13:49:33 +00:00
|
|
|
// planets
|
2021-04-09 14:28:37 +00:00
|
|
|
planets = new Group();
|
2021-04-09 13:49:33 +00:00
|
|
|
|
|
|
|
Planet planet1 = new Planet(new Vector2(400, 400), 1000, 50, Color.BLUE);
|
|
|
|
planets.addActor(planet1);
|
|
|
|
|
2021-04-09 13:03:24 +00:00
|
|
|
Planet planet2 = new Planet(new Vector2(1400, 700), 1000, 100, Color.ORANGE);
|
2021-04-09 13:49:33 +00:00
|
|
|
planet2.addMoon(new Moon(planet2, 100, 10, 300, Color.MAGENTA));
|
|
|
|
planets.addActor(planet2);
|
2021-04-09 13:03:24 +00:00
|
|
|
|
2021-04-09 13:49:33 +00:00
|
|
|
mainStage.addActor(planets);
|
|
|
|
|
|
|
|
// players
|
2021-04-09 13:10:39 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
Player player1 = new Player(planet1, Color.WHITE);
|
|
|
|
mainStage.addActor(player1);
|
2021-04-09 13:03:24 +00:00
|
|
|
|
2021-04-09 13:49:33 +00:00
|
|
|
// others
|
|
|
|
|
2021-04-09 13:03:24 +00:00
|
|
|
FPS fpsCounter = new FPS();
|
|
|
|
uiStage.addActor(fpsCounter);
|
|
|
|
|
|
|
|
MouseInfo mouseInfo = new MouseInfo();
|
|
|
|
uiStage.addActor(mouseInfo);
|
2021-04-09 13:10:39 +00:00
|
|
|
|
2021-04-05 16:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-04-09 09:57:52 +00:00
|
|
|
public void update(float dt) {
|
2021-04-09 13:03:24 +00:00
|
|
|
|
|
|
|
screenCursor = new Vector2(Gdx.input.getX(), Gdx.input.getY());
|
|
|
|
unprojectedCursor = mainStage.getCamera().unproject(new Vector3(screenCursor, 0));
|
|
|
|
worldCursor = new Vector2(unprojectedCursor.x, unprojectedCursor.y);
|
|
|
|
|
2021-04-05 16:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|