diff --git a/AsteroidsGame.pde b/AsteroidsGame.pde index de9044b11..c5896a161 100644 --- a/AsteroidsGame.pde +++ b/AsteroidsGame.pde @@ -1,10 +1,30 @@ //your variable declarations here -public void setup() +Spaceship bob; +Star s[] = new Star[200]; + +public void setup() { - //your code here + size(500, 500); + bob = new Spaceship(); + for (int i = 0; i < 200; i++) { + s[i] = new Star(); + } } -public void draw() +public void draw() +{ + background(0); + for (int i = 0; i < 200; i++) { + s[i].show(); + } +} +public void keyPressed() { - //your code here + if ( key == 'q' || key == 'Q') { + bob.setX((int)(Math.random()*width)); + bob.setY((int)(Math.random()*height)); + bob.myXspeed = 0; + bob.myYspeed = 0; + bob.setPointDirection((int)(Math.random()*36)*10); + background(0); + } } -