-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDestroyableTile.java
61 lines (48 loc) · 1.18 KB
/
DestroyableTile.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
59
60
61
package uet.oop.bomberman.entities.tile.destroyable;
import uet.oop.bomberman.entities.Entity;
import uet.oop.bomberman.entities.tile.Tile;
import uet.oop.bomberman.graphics.Sprite;
/**
* Đối tượng cố định có thể bị phá hủy
*/
public class DestroyableTile extends Tile {
private final int MAX_ANIMATE = 7500;
private int _animate = 0;
protected boolean _destroyed = false;
protected int _timeToDisapear = 20;
protected Sprite _belowSprite = Sprite.grass;
public DestroyableTile(int x, int y, Sprite sprite) {
super(x, y, sprite);
}
@Override
public void update() {
if(_destroyed) {
if(_animate < MAX_ANIMATE) _animate++; else _animate = 0;
if(_timeToDisapear > 0)
_timeToDisapear--;
else
remove();
}
}
public void destroy() {
_destroyed = true;
}
@Override
public boolean collide(Entity e) {
// TODO: xử lý khi va chạm với Flame
return false;
}
public void addBelowSprite(Sprite sprite) {
_belowSprite = sprite;
}
protected Sprite movingSprite(Sprite normal, Sprite x1, Sprite x2) {
int calc = _animate % 30;
if(calc < 10) {
return normal;
}
if(calc < 20) {
return x1;
}
return x2;
}
}