forked from APCSLowell/AsteroidsGame
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBullet.pde
More file actions
44 lines (44 loc) · 1.09 KB
/
Bullet.pde
File metadata and controls
44 lines (44 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Bullet extends Floater{
private double mySpeed;
private boolean outOfBounds;
public Bullet(double x, double y, double dir){
myCenterX = x;
myCenterY = y;
myPointDirection = dir;
mySpeed = 5;
outOfBounds = false;
myColor = 200;
}
public Bullet(double x, double y, double dir, int c){
myCenterX = x;
myCenterY = y;
myPointDirection = dir;
mySpeed = 5;
outOfBounds = false;
myColor = c;
}
public double getX(){
return myCenterX;
}
public double getY(){
return myCenterY;
}
public boolean getOutOfBounds(){
return outOfBounds;
}
public void move(){
double dRadians =myPointDirection*(Math.PI/180);
myXspeed = mySpeed * Math.cos(dRadians);
myYspeed = mySpeed * Math.sin(dRadians);
myCenterX += myXspeed;
myCenterY += myYspeed;
if(myCenterX > width || myCenterX < 0 || myCenterY > height || myCenterY < 0){
outOfBounds = true;
}
}
public void show(){
fill(myColor);
stroke(0);
ellipse((float)myCenterX, (float)myCenterY, 5, 5);
}
}