-
Notifications
You must be signed in to change notification settings - Fork 0
/
tetris_clear.h
60 lines (43 loc) · 987 Bytes
/
tetris_clear.h
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
#ifndef __TETRIS_CLEAR_H__
#define __TETRIS_CLEAR_H__
class tetris_clear : public animation {
public:
tetris_clear(tetris_player *parent_anim, uint32_t rows_anim) {
parent = parent_anim;
rows = rows_anim;
parent->pause(true);
paused = parent->elapsed;
}
virtual ~tetris_clear() {
parent->pause(false);
parent->elapsed = paused;
}
INLINE uint8_t id() const { return parent->id(); }
virtual void frame(pixelArray **strip, WII **wii) {
if (elapsed > 1000) {
elapsed -= 1000;
paused -= elapsed;
for (uint32_t i=0; i<TETRIS_HEIGHT; i++) {
if ((1L<<i) & rows) {
parent->clear(i);
}
}
delete this;
return;
}
for (uint32_t y=0; y<TETRIS_HEIGHT; y++) {
if (!(rows & 1L<<y)) continue;
for (int x=0; x<TETRIS_WIDTH; x++) {
strip[id()]->draw(
x + parent->align_x(),
y + parent->align_y()
);
}
}
}
private:
tetris_player *parent;
int32_t paused;
uint32_t rows;
};
#endif //__TETRIS_CLEAR_H__