-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAsteroid.java
More file actions
executable file
·36 lines (30 loc) · 1.04 KB
/
Copy pathAsteroid.java
File metadata and controls
executable file
·36 lines (30 loc) · 1.04 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
/**
* @author Todd Pickell CISS 238
* Chapter
* Programming Challenge pg
*/
import java.awt.*;
/*********************************************************
* Asteroid class derives from BaseVectorShape
**********************************************************/
public class Asteroid extends VectorEntity {
//define the asteroid polygon shape
private int[] astx = {-20,-13, 0,20,22, 20, 12, 2,-10,-22,-16};
private int[] asty = { 20, 23,17,20,16,-20,-22,-14,-17,-20, -5};
//rotation speed
protected double rotVel;
public double getRotationVelocity() { return rotVel; }
public void setRotationVelocity(double v) { rotVel = v; }
//bounding rectangle
public Rectangle getBounds() {
Rectangle r;
r = new Rectangle((int)getX() - 20, (int) getY() - 20, 40, 40);
return r;
}
//default constructor
Asteroid() {
setShape(new Polygon(astx, asty, astx.length));
setAlive(true);
setRotationVelocity(0.0);
}
}