-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFFlag.pde
More file actions
48 lines (44 loc) · 857 Bytes
/
FFlag.pde
File metadata and controls
48 lines (44 loc) · 857 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
42
43
44
45
46
47
48
class FFlag extends FGameObject {
int frame;
int flagX;
int flagY;
int flagNumber = 0;
int k = 1;
float xSet;
float ySet;
FFlag(float x, float y) {
super();
setPosition(x, y);
setStatic(true);
setSensor(true);
setName("flagTile");
xSet = x;
ySet = y;
}
void act() {
animate();
collide();
}
void animate() {
action = flag;
if (frame >= action.length) frame = 0;
if (frameCount % objectRefresh == 0) {
attachImage(flag[frame]);
frame++;
}
}
void collide() {
if (isTouching("player") && k == 1) {
flagNumber++;
k = 0;
if (flagNumber == 1) {
spawnX = xSet;
spawnY = ySet;
}
if (flagNumber == 2) {
spawnX = xSet;
spawnY = ySet;
}
}
}
}