-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoblins.pde
More file actions
49 lines (37 loc) · 1.17 KB
/
Goblins.pde
File metadata and controls
49 lines (37 loc) · 1.17 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
class Goblins extends EnemyModel {
int life = 1;
Goblins(int xpos, int ypos) {
x = xpos;
y = ypos;
}
//This determines how the Goblin army moves
void updateObj() {
x += direction * (speed / 2);
if (wall == true) {
y += gridsize / 2;
}
}
//Checks the life of the Goblins when they are hit by fireball
boolean alive() {
for (int i = 0; i < fireballs.size(); i++) {
Fireball fireball = (Fireball) fireballs.get(i);
if (fireball.x > x && fireball.x < x + 7 * pixelsize + 5 && fireball.y > y && fireball.y < y + 5 * pixelsize) {
fireballs.remove(i);
life--;
if (life == 0) {
score += 50;
return false;
}
break;
}
}
return true;
}
int reachCastle(){
return y;
}
//Keeps the goblins within the game
boolean outside() {
return x + (gridsize) < 30 || x + (gridsize) > width - gridsize;
}
}