Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AsteroidsGame.pde #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions AsteroidsGame.pde
Original file line number Diff line number Diff line change
@@ -1,10 +1,74 @@
//your variable declarations here
Star [] david;
Spaceship bob;
public void setup()
{
size(500,500);
bob = new Spaceship();
david = new Star [500];


for(int i =0; i < david.length; i++) {
david[i] = new Star();
}

//your code here
}
public void draw()
{
background(0);
noStroke();
for(int i =0; i < david.length; i++) {

david[i].show();
}

bob.show();
bob.move();
//your code here
}


public void keyPressed() {
if (key == 'w') {
bob.accelerate(.1);

}

if(key == 's') {
bob.accelerate(-.1);
}

if(key == 'd') {
bob.turn(10);
}

if(key == 'a') {
bob.turn(-10);
}

}


public void keyReleased() {
if (key == 'w') {
bob.setYSpeed(0);
bob.setXSpeed(0);
}

if(key == 's') {
bob.setYSpeed(0);
bob.setXSpeed(0);
}

if (key == 'h') {
int bomba = (int)(Math.random()500);
int bomb = (int)(Math.random()500);
int wilbur = (int)(Math.random()360);
bob.setX(bomba);
bob.setY(bomb);
bob.setYSpeed(0);
bob.setXSpeed(0);
bob.setDirect((double)wilbur);
}
}