Debian Codegraph @

Oodle/src/CFadeToLayerEffect.h

raw
1 #ifndef _CFADETOLAYEREFFECT_
2 #define _CFADETOLAYEREFFECT_
3
4 #include "CTimedEvent.h"
5
6 class CFadeToLayerEffect : public CTimedEvent
7 {
8 public:
9 CFadeToLayerEffect(unsigned int duration, const CSurface &s1, const CSurface &s2, bool concurrent = false) : CTimedEvent(0,concurrent), duration(duration), s1(s1), s2(s2) {}
10
11 void draw(CSurface &s, int x, int y) {
12 Uint32 tick = ticksElapsed();
13 if (((double)duration-tick) <= 0)
14 {
15 s.blit(s2, x, y);
16 setConcurrent();
17 return;
18 }
19
20 s2.setAlpha(SDL_SRCALPHA, (Uint8)(255-(255*(((double)duration - tick) / duration))));
21 s.blit(s1, x, y);
22 s.blit(s2, x, y);
23 }
24 void doUpdate() {}
25 bool hasDraw() { return true; }
26
27 CFadeToLayerEffect* getCopy() { return new CFadeToLayerEffect(*this); }
28
29 private:
30 CSurface s1, s2;
31 unsigned int duration;
32 };
33
34 #endif