forked from tapickell/JavaStuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShip.java
More file actions
42 lines (37 loc) · 738 Bytes
/
Copy pathShip.java
File metadata and controls
42 lines (37 loc) · 738 Bytes
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
/**
* @author Todd Pickell CISS 238
* Chapter
* Programming Challenge pg
*/
import java.awt.*;
/**
* @author Todd Pickell CISS 238
* Chapter
* Programming Challenge pg
*/
public class Ship extends BaseVectorShape
{
//define ship polygon
private int[] shipX = {-6, -3, 0, 3, 6, 0};
private int[] shipY = {6, 7, 7, 7, 6, -7};
//bounding rectangle
public Rectangle getBounds()
{
Rectangle r;
r = new Rectangle((int)getX() - 6, (int)getY() - 6, 12, 12);
return r;
}
Ship()
{
setShape(new Polygon(shipX, shipY, shipX.length));
setAlive(true);
}
public void reset()
{
this.setX(320);
this.setY(240);
this.setFaceAngle(0);
this.setVelX(0);
this.setVelY(0);
}
}