-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlien.pde
177 lines (130 loc) · 3.3 KB
/
Alien.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
class Alien {
float aX;
float aY;
float aS;
float mod = 1;
boolean destr =false;
int health;
float rad = 12;
//boolean move = false;
float direction =1;
int score = 20;
Alaser alaser;
float introDirection = 1;
boolean alive = true;
int d;
//ArrayList alasers = new ArrayList();
Alien (float aX,float aY,float aS){
this.aX = aX;
this.aY = aY;
this.aS = aS;
}
void display(){
if (!destr)
RenderAlien();
else
RenderExplosion();
}
void move(float mod){
aX+=(aS*mod)*direction;
if (aY>height)
STATE = GAMEOVER;
}
void destroy(){
destr = true;
}
void RenderAlien(){
d = millis()/250%2;
fill (255);
switch(d){
case 0:
strokeWeight(0);
rect(aX+4,aY,12,2);// ******
rect(aX+4,aY+2,2,2);// * ** *
rect(aX+8,aY+2,4,2);// ******
rect(aX+14,aY+2,2,2);// ********
rect(aX+4,aY+4,2,12);// * ****** *
rect(aX+2,aY+6,16,2);// * ****** *
rect(aX,aY+8,2,2);// ******
rect(aX+4,aY+8,12,2);// * *
rect(aX+18,aY+8,2,2);// * *
rect(aX,aY+10,2,2);// *** ***
rect(aX+4,aY+10,12,2);
rect(aX+18,aY+10,2,2);
rect(aX+4,aY+12,12,2);
rect(aX+6,aY+14,2,2);
rect(aX+12,aY+14,2,2);
rect(aX+4,aY+16,2,2);
rect(aX+14,aY+16,2,2);
rect(aX,aY+18,6,2);
rect(aX+14,aY+18,6,2);
break;
case 1:
strokeWeight(0);
rect(aX+4,aY,12,2);
rect(aX,aY+2,2,2);// ******
rect(aX+4,aY+2,2,2);// * * ** * *
rect(aX+8,aY+2,4,2);// * ****** *
rect(aX+14,aY+2,2,2);// ********
rect(aX+18,aY+2,2,2);// ******
rect(aX,aY+4,2,2);// ******
rect(aX+4,aY+4,2,12);// ******
rect(aX+18,aY+4,2,2);// * *
rect(aX+2,aY+6,16,2);// * *
rect(aX+4,aY+8,12,2);// * *
rect(aX+4,aY+10,12,2);
rect(aX+4,aY+12,12,2);
rect(aX+2,aY+14,2,2);
rect(aX+16,aY+14,2,2);
rect(aX,aY+16,2,2);
rect(aX+18,aY+16,2,2);
rect(aX,aY+18,2,2);
rect(aX+18,aY+18,2,2);
break;
}
}
void RenderExplosion(){
rect (aX,aY,2,2);
rect (aX+4,aY,2,2);
rect (aX+8,aY,2,2);
rect (aX+14,aY,2,2);
rect (aX+18,aY,2,2);
rect (aX+2,aY+2,2,2);
rect (aX+8,aY+2,2,2);
rect (aX+16,aY+2,2,2);
rect (aX,aY+4,2,2);
rect (aX+4,aY+4,2,2);
rect (aX+8,aY+4,2,2);
rect (aX+14,aY+4,2,2);
rect (aX+6,aY+6,2,2);
rect (aX+12,aY+6,2,2);
rect (aX+8,aY+8,12,2);
rect (aX,aY+10,12,2);
rect (aX+6,aY+12,2,2);
rect (aX+10,aY+12,4,2);
rect (aX+4,aY+14,2,2);
rect (aX+10,aY+14,2,2);
rect (aX+14,aY+14,2,2);
rect (aX+18,aY+14,2,2);
rect (aX+2,aY+16,2,2);
rect (aX+10,aY+16,2,2);
rect (aX+16,aY+16,2,2);
rect (aX+2,aY+18,2,2);
rect (aX+4,aY+18,2,2);
rect (aX+10,aY+18,2,2);
rect (aX+14,aY+18,2,2);
rect (aX+18,aY+18,2,2);
}
void introMove(){
aX+=aS*introDirection;
}
boolean collide(){
return aX>space.sX &&aX<space.sX+25 && aY>space.sY && aY<space.sY+25;
}
int getScore() {
return score;
}
Alaser shoot() {
return new Alaser(aX+13,aY+25);
}
}