-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlaze.java
58 lines (47 loc) · 1.31 KB
/
Blaze.java
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
import mayflower.*;
import kuusisto.tinysound.*;
public class Blaze extends Actor {
private MayflowerImage left;
private MayflowerImage right;
private String dir;
private int ogx, ogy;
public Blaze(int x, int y) {
ogx = x;
ogy = y;
left = new MayflowerImage("assets/blaze.png");
right = new MayflowerImage(left);
right.mirrorHorizontally();
left.scale(50, 85);
right.scale(50, 85);
dir = "left";
setImage(left);
}
public void act() {
int x = getX();
int y = getY();
int h = getHeight();
if (isTouching(Cat.class)) {
Cat c = getOneIntersectingObject(Cat.class);
setLocation(ogx, ogy);
Music m = TinySound.loadMusic("assets/music/oof.wav");
m.play(false);
dir = "left";
c.respawn();
c.decrHealth(25);
}
if (dir.equals("right") && x <= 800 - h) {
setLocation(x + 1, y);
setImage(right);
if (x >= 800 - h) {
dir = "left";
}
}
if (dir.equals("left") && x >= 0) {
setImage(left);
setLocation(x - 1, y);
if (x <= 0) {
dir = "right";
}
}
}
}