printFPS(1000);
}
@Override
public void onAdd() {
Material earthImage = new Material(loadTexture(new File("textures/earth.png")));
float earthWidth = 6378.1e3f * 2;
ViewModel earthSprite = ellipse(earthImage, earthWidth, earthWidth, 100);
earth = new Entity(earthSprite);
earth.pos = new Vector3(getCanvasWidth() / 4, getCanvasHeight() / 4, 0);
earth.addBehavior(new RigidBody());
earth.rigidBody().mass = 5.97219e24f;
Material moonImage = new Material(loadTexture(new File("textures/moon.png")));
float moonWidth = 1737.4e3f * 2;
ViewModel moonSprite = ellipse(moonImage, moonWidth, moonWidth, 100);
moon = new Entity(moonSprite);
moon.pos = new Vector3(earth.pos.x - 384400e3f, earth.pos.y);
moon.addBehavior(new RigidBody());
moon.rigidBody().mass = 7.34767309e22f;
yesThrust = new Material(loadTexture("nothrust", new File("textures/ship.png")));
yesThrust.setTextureFilter(Material.Filter.MIPMAP, Material.Filter.NEAREST);
noThrust = new Material(loadTexture("thrust", new File("textures/ship_thrust.png")));
noThrust.setTextureFilter(Material.Filter.MIPMAP, Material.Filter.NEAREST);
ViewModel model = rect2D(noThrust, 37.5f, 50f);
ship = new Entity(model);
ship.pos = new Vector3(earth.pos.x, earth.pos.y + earthWidth / 2 + 300e3f);
ship.addBehavior(new RigidBody());
ship.rigidBody().mass = 78e3f;
ship.rigidBody().velocity.x = 7700f;
earthGravity = new PointGravity(earth);
moonGravity = new PointGravity(moon);
ship.rigidBody().addForce(earthGravity);
ship.rigidBody().addForce(moonGravity);
//earth.rigidBody().addForce(moonGravity);
//moon.rigidBody().addForce(earthGravity);
background = rect2D(new Material(loadTexture(new File("textures/background.png"))), 4, 3, 800, 600);
viewpoint = new ScreenViewpoint(Vector2.zero(), 1 / 32768f, 0) {
@Override
public Vector2 cameraPosition() {
return ship.pos.xy();