Debian Codegraph @

TetrisAttack/src/CBlockDeathEffect.h

raw
1 #ifndef _CBLOCKDEATHEFFECT_
2 #define _CBLOCKDEATHEFFECT_
3
4 #include "CSequencedEvent.h"
5
6 class CBlockDeathEffect : public CTimedEvent
7 {
8 public:
9 CBlockDeathEffect(CBlock &b, CSurface *death) : CTimedEvent(50,true), death(death), b(b), count(0), x((int)b.getPos().getX()), y((int)b.getPos().getY()) { }
10 CBlockDeathEffect* getCopy() { return new CBlockDeathEffect(*this); }
11 ~CBlockDeathEffect() { delete death; }
12
13 void initialize()
14 {CTimedEvent::initialize(); b.appendEvent( new CFadeToLayerEffect(500, *b.getCurrentFrame(), *death, true) ); }
15 void doUpdate() {
16 bool t = CTimedEvent::updateTime();
17 if (t && count % 2 == 0)
18 {
19 b.setPos(CVector(x, y+2));
20 count++;
21 }
22 else if (t)
23 {
24 b.setPos(CVector(x, y-2));
25 count++;
26 }
27
28 if (count > 10) { b.setPos(CVector(x,y)); setDone(); }
29 }
30
31 private:
32 CBlock &b;
33 CSurface *death;
34 int x, y;
35 int count;
36 };
37
38 #endif