public class Simulator { public static void main(String[] args) { Asteroid[] asteroids = new Asteroid[15]; for( int i = 0; i < asteroids.length; i++ ) asteroids[i] = new Asteroid( Math.random(), Math.random(), Math.random() * .05 + .01, Math.random()*.5 - .25, Math.random()*.5 - .25 ); Ship ship; do { ship = new Ship( Math.random(), Math.random(), .02, 0, 0 ); } while ( ship.collides(asteroids) ); final int MILLISECONDS = 10; final double STEP = MILLISECONDS/1000.0; StdDraw.enableDoubleBuffering(); while( ship.isAlive() ) { StdDraw.clear(); StdDraw.setPenColor(); StdDraw.square(.5, .5, .5); for( int i = 0; i < asteroids.length; ++i ) { asteroids[i].update( STEP ); asteroids[i].draw(); } ship.update(asteroids, STEP, StdDraw.mouseX(), StdDraw.mouseY() ); ship.draw(); StdDraw.show(); StdDraw.pause( MILLISECONDS ); } } }