-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUFO.java
More file actions
84 lines (61 loc) · 1.43 KB
/
Copy pathUFO.java
File metadata and controls
84 lines (61 loc) · 1.43 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.awt.Color;
import java.awt.Graphics;
public class UFO extends PolygonModel {
int velX;
static int[][] xStruct = {
};
static int [][] yStruct = {
};
int rectX = 60;
int rectY = 75;
Rect r;
int health = 3;
boolean alive = true;
int crashDMG = 60;
public UFO(int x, int y, int velX) {
super(x, y, xStruct, yStruct);
this.velX = velX;
r = new Rect(x - (rectX/2), y -(rectY/2) - 5, rectX, rectY);
}
public int getVelX(){
return velX;
}
public void setVelX(int var){
velX = var;
}
public int getCrashDMG(){
return crashDMG;
}
public void hit(){
health--;
if(health <= 0)
alive = false;
}
public void moveDownBy(int var){
y += var;
}
public void moveSidewaysBy(int var){
x += var;
}
public void draw(Graphics g){
//Draws bounding box for object
r.setX(x - (rectX/2));
r.setY(y -(rectY/2) - 5);
//r.draw(g);
//Draws the object on the window
//top
g.setColor(Color.white);
g.fillOval(x - rectX/3, y -(rectY/2) - 5, 40, 60);
g.setColor(Color.black);
g.drawOval(x - rectX/3, y -(rectY/2) - 5, 40, 60);
//bottom
g.setColor(Color.DARK_GRAY);
g.fillOval(x - rectX/2, y - 10, 60, 40);
//orb
g.setColor(Color.green);
g.fillOval(x + 15, y + 5, 12, 12);
g.fillOval(x - 5, y + 5, 12, 12);
g.fillOval(x - 25, y + 5, 12, 12);
g.setColor(Color.BLACK);
}
}