@Override public void simpleUpdate(float tpf) { for (Planet planet : planets) { planet.getGeom().rotate(0, 0, planet.getRotationSpeed() * tpf); planet.getPivot().rotate(0, planet.getTranslationSpeed() * tpf, 0); } for (Spatial spatial : explosions.getChildren()) { ParticleEmitter explosion = (ParticleEmitter) spatial; if (explosion.getNumVisibleParticles() < 1) { explosion.removeFromParent(); } } Vector3f rotation = new Vector3f(0, 0, 0); if (left) { rotation.addLocal(0, 1, 0); } if (right) { rotation.addLocal(0, -1, 0); } if (up) { rotation.addLocal(1, 0, 0); } if (down) { rotation.addLocal(-1, 0, 0); } if (leftSide) { rotation.addLocal(0, 0, 1); } if (rightSide) { rotation.addLocal(0, 0, -1); } Vector3f transformed = new Vector3f(0, 0, 0); spaceship.getLocalRotation().mult(rotation, transformed); spaceship.getControl().setAngularVelocity(transformed); Vector3f movement = new Vector3f(0, 0, 0); if (moving) { spaceship.getWorldRotation().mult(new Vector3f(0, 0, -6), movement); } spaceship.getControl().setLinearVelocity(movement); bloom.setBloomIntensity(bloom.getBloomIntensity() + (bloomDirection * tpf / 8)); if (bloom.getBloomIntensity() > 4) { bloomDirection = -1; } if (bloom.getBloomIntensity() < 2) { bloomDirection = 1; } Vector3f direction = spaceship.getRear().getWorldTranslation().subtract(cam.getLocation()); float magnitude = direction.length(); if (magnitude > 0) { cam.setLocation( cam.getLocation().add(direction.normalize().mult(tpf * magnitude * magnitude / 2))); } cam.lookAt(spaceship.getFront().getWorldTranslation(), Vector3f.UNIT_Y); for (Spatial spatial : asteroids.getChildren()) { if (spatial.getWorldTranslation().subtract(Vector3f.ZERO).length() > 200) { spatial.removeFromParent(); } } if (Math.random() < 0.01 && asteroids.getChildren().size() < MAX_ASTEROIDS) { generateRandomAsteroid(); } for (Spatial spatial : lasers.getChildren()) { Laser laser = (Laser) spatial; if (laser.getWorldTranslation().subtract(Vector3f.ZERO).length() > 200) { bap.getPhysicsSpace().remove(laser.getControl()); laser.removeFromParent(); continue; } laser.move(laser.getDirection().mult(laser.getSpeed())); } scoreText.setText("Score: " + score); }