-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardParticle.adept
218 lines (174 loc) · 6.66 KB
/
CardParticle.adept
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import 'main.adept'
struct CardParticle (
network_id CardNetworkID,
texture *CaptTexture,
width, height, y_offset float,
start, duration double,
after ptr
) {
func shouldEnd bool {
return glfwGetTime() >= this.start + this.duration
}
func deleteChildren {
to_delete <*CardParticle> List
after *CardParticle = this.getNext()
while after {
to_delete.add(after)
after = after.getNext()
}
each *CardParticle in to_delete, delete it
}
func getNext() *CardParticle = this.after as *CardParticle
}
func advanceParticles(this *<*CardParticle> List) {
each *CardParticle in *this {
// Don't advance animations that are still running
unless it.shouldEnd(), continue
// Remove completed animations that don't have any children
unless it.getNext(), delete it; this.remove(idx--); continue
dead_parent *CardParticle = it
it = it.getNext()
it.start = glfwGetTime()
delete dead_parent
}
}
func newCardParticle(network_id CardNetworkID, texture *CaptTexture, width, height, y_offset float, duration_in_seconds double, after *CardParticle) *CardParticle {
// NOTE: Returns allocated memory
particle *CardParticle = new CardParticle
particle.network_id = network_id
particle.texture = texture
particle.width = width
particle.height = height
particle.y_offset = y_offset
particle.start = 0.0
particle.duration = duration_in_seconds
particle.after = after
return particle
}
func newCardParticle(network_id CardNetworkID, frames <*CaptTexture> List, width, height, y_offset float, durations <double> List) *CardParticle {
// NOTE: Returns allocated memory
unless frames.length == durations.length {
print("ERROR: newCardParticle(CardNetworkID, <*CaptTexture> List, float, float <double> List) *CardParticle : frames.length doesn't match durations.length")
print(" (returning null)")
return null
}
particle *CardParticle = null
child *CardParticle = null
repeat frames.length {
if particle == null {
particle = newCardParticle(network_id, frames.get(0), width, height, y_offset, durations.get(0), null)
child = particle
continue
}
child.after = newCardParticle(network_id, frames.get(idx), width, height, y_offset, durations.get(idx), null)
child = child.getNext()
}
return particle
}
// ---------------------------------------------------------
func addAttackBonus(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.popup_attack1)
durations.add(0.25f)
frames.add(&textures.popup_attack2)
durations.add(0.25f)
frames.add(&textures.popup_attack3)
durations.add(1.0f)
this.spawn(newCardParticle(network_id, frames, 50.0f, 50.0f, 0.0f, durations))
}
func addPopupShield(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.popup_shield1)
durations.add(0.25f)
frames.add(&textures.popup_shield2)
durations.add(0.25f)
frames.add(&textures.popup_shield3)
durations.add(1.0f)
this.spawn(newCardParticle(network_id, frames, 50.0f, 50.0f, 0.0f, durations))
}
func addSmite(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.smite1)
durations.add(0.1f)
frames.add(&textures.smite2)
durations.add(0.1f)
frames.add(&textures.smite3)
durations.add(0.1f)
frames.add(&textures.smite4)
durations.add(0.1f)
frames.add(&textures.smite5)
durations.add(0.1f)
this.spawn(newCardParticle(network_id, frames, 48.0f, 96.0f, -24.0f, durations))
}
func addHealing(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.heal1)
durations.add(0.25f)
frames.add(&textures.heal2)
durations.add(0.25f)
frames.add(&textures.heal3)
durations.add(0.25f)
this.spawn(newCardParticle(network_id, frames, 50.0f, 50.0f, 0.0f, durations))
}
func addResistance(this *<*CardParticle> List, network_id CardNetworkID) {
this.spawn(newCardParticle(network_id, &textures.resistance, 50.0f, 50.0f, 0.0f, 2.0f, null))
}
func addTransform(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.transform1)
durations.add(0.25f)
frames.add(&textures.transform2)
durations.add(0.25f)
this.spawn(newCardParticle(network_id, frames, 50.0f, 50.0f, 0.0f, durations))
}
func addTrap(this *<*CardParticle> List, network_id CardNetworkID) {
this.spawn(newCardParticle(network_id, &textures.trap, 108.0f, 24.0f, CHARACTER_HEIGHT / -2.0f - 12.0f, 0.25f, null))
}
func addFloorSpikes(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.floor_spikes1)
durations.add(0.5f)
frames.add(&textures.floor_spikes2)
durations.add(0.5f)
this.spawn(newCardParticle(network_id, frames, 32.0f, 32.0f, 0.0f, durations))
}
func addReflectiveShield(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.reflective_shield1)
durations.add(0.25f)
frames.add(&textures.reflective_shield2)
durations.add(0.5f)
this.spawn(newCardParticle(network_id, frames, 50.0f, 50.0f, 0.0f, durations))
}
func addPartyPopper(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.party_popper1)
durations.add(0.5f)
frames.add(&textures.party_popper2)
durations.add(0.5f)
this.spawn(newCardParticle(network_id, frames, 50.0f, 50.0f, 0.0f, durations))
}
func addExplosion(this *<*CardParticle> List, network_id CardNetworkID) {
frames <*CaptTexture> List
durations <double> List
frames.add(&textures.transparency)
durations.add(0.5f)
frames.add(&textures.explosion1)
durations.add(0.25f)
frames.add(&textures.explosion2)
durations.add(0.25f)
this.spawn(newCardParticle(network_id, frames, 50.0f, 50.0f, 0.0f, durations))
}
func spawn(this *<*CardParticle> List, particle *CardParticle) {
// NOTE: Takes ownership of 'particle *CardParticle'
particle.start = glfwGetTime()
this.add(particle)
}