From 0632da853005a3d2fad9c84e0d0a95ef91c13a0c Mon Sep 17 00:00:00 2001 From: louisc96 <143375801+louisc96@users.noreply.github.com> Date: Fri, 24 Nov 2023 00:14:40 -0800 Subject: [PATCH] Update AsteroidsGame.pde --- AsteroidsGame.pde | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) 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); + } } -