-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemo.cpp
71 lines (62 loc) · 1.2 KB
/
Demo.cpp
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
69
70
71
/**
* Mac Demo
* Copyright (C) 2009 by Sami Kyostila <[email protected]>
*/
#include "Demo.h"
Timeline::Timeline(EffectEntry* effects):
m_effects(effects),
m_firstEffect(effects),
m_baseTime(0)
{
}
bool Timeline::run(int time)
{
int t = m_baseTime;
EffectEntry* f = m_effects;
if (f->flags & EFFECT_FLAG_DYNAMIC_DONE)
{
m_baseTime = time;
m_effects++;
return 1;
}
while (t + f->duration < time)
{
if (f->flags & EFFECT_FLAG_DYNAMIC)
{
break;
}
if (!f->duration)
{
return 0;
}
t += f->duration;
m_baseTime += f->duration;
f++;
}
if (f->flags & EFFECT_FLAG_DYNAMIC)
{
int dt = time - t;
if (f->effect(dt, dt))
{
if (!(f->flags & EFFECT_FLAG_INFINITESIMAL))
{
f->flags |= EFFECT_FLAG_DYNAMIC_DONE;
}
else
{
f++;
}
}
}
else
{
f->effect(time - t, f->duration);
}
m_effects = f;
return 1;
}
void Timeline::reset()
{
m_effects = m_firstEffect;
m_baseTime = 0;
}