-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRocketFire.java
More file actions
41 lines (33 loc) · 891 Bytes
/
RocketFire.java
File metadata and controls
41 lines (33 loc) · 891 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
package com.javarush.games.moonlander;
import com.javarush.engine.cell.*;
import java.util.List;
public class RocketFire extends GameObject {
private List<int[][]> frames;
private int frameIndex;
private boolean isVisible;
public RocketFire(List<int[][]> frameList) {
super(0, 0, frameList.get(0));
frames = frameList;
frameIndex = 0;
isVisible = false;
}
private void nextFrame() {
frameIndex += 1;
if (frameIndex >= frames.size())
frameIndex = 0;
matrix = frames.get(frameIndex);
}
@Override
public void draw(Game game) {
if (!isVisible)
return;
nextFrame();
super.draw(game);
}
public void show() {
isVisible = true;
}
public void hide() {
isVisible = false;
}
}