forked from APCSLowell/AsteroidsGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBullet.pde
55 lines (55 loc) · 1.25 KB
/
Bullet.pde
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
45
46
47
48
49
50
51
52
53
54
55
class Bullet extends Floater
{
double dRadians;
public Bullet(Spaceship theShip)
{
myCenterX = theShip.getX();
myCenterY = theShip.getY();
myPointDirection = theShip.getPointDirection();
dRadians =myPointDirection*(Math.PI/180);
myDirectionX = 10*Math.cos(dRadians) + theShip.getDirectionX();
myDirectionY = 10*Math.sin(dRadians) + theShip.getDirectionY();
myColor = 239;
}
public void setX(int x) {
myCenterX=x;
}
public int getX() {
return (int)myCenterX;
}
public void setY(int y) {
myCenterY=y;
}
public int getY() {
return (int)myCenterY;
}
public void setDirectionX(double x) {
myDirectionX=x;
}
public double getDirectionX() {
return myDirectionX;
}
public void setDirectionY(double y) {
myDirectionY=y;
}
public double getDirectionY() {
return myDirectionY;
}
public void setPointDirection(int degrees) {
myPointDirection=degrees;
}
public double getPointDirection() {
return myPointDirection;
}
public void show()
{
fill(myColor, 208, 33);
stroke(myColor, 208, 33);
ellipse((float)myCenterX,(float)myCenterY,15,15);
}
public void move()
{
myCenterX += myDirectionX;
myCenterY += myDirectionY;
}
}