-
Notifications
You must be signed in to change notification settings - Fork 2
/
LineClearAnimator.pde
68 lines (51 loc) · 1.41 KB
/
LineClearAnimator.pde
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
62
63
64
65
66
67
68
public class ClearLineAnimator{
private Ticker lifeTimeTicker;
private Ticker ticker;
private ArrayList rowIndicesToClear;
//private ArrayList<float> sd;
private boolean alive;
private boolean doesAffectBoard;
private boolean drawingClearLine;
public boolean isAlive(){
return alive;
}
public ClearLineAnimator(){
ticker = new Ticker();
lifeTimeTicker = new Ticker();
alive = true;
doesAffectBoard = true;
drawingClearLine = true;
}
public void setRowIndicesToClear(ArrayList rowIndicesToClear){
this.rowIndicesToClear = rowIndicesToClear;
}
public boolean DoesAffectBoard(){
return doesAffectBoard;
}
public void update(){
ticker.tick();
lifeTimeTicker.tick();
if(lifeTimeTicker.getTotalTime() > 0.25f){
doesAffectBoard = false;
}
if(lifeTimeTicker.getTotalTime() > 0.25f){
alive = false;
}
if(ticker.getTotalTime() > 0.01f){
ticker.reset();
drawingClearLine = !drawingClearLine;
}
}
public void draw(){
if(drawingClearLine){
noStroke();
fill(0);
pushMatrix();
translate(BOARD_START_X + BLOCK_SIZE, BOARD_START_Y);
for(int i = 0; i < rowIndicesToClear.size(); i++){
rect(0, ((Integer)rowIndicesToClear.get(i)) * BLOCK_SIZE, (NUM_COLS-2) * BLOCK_SIZE, BLOCK_SIZE);
}
popMatrix();
}
}
}