-
Notifications
You must be signed in to change notification settings - Fork 2
/
particlefx.monkey
167 lines (152 loc) · 6.24 KB
/
particlefx.monkey
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
Import horizon.particleemitter
Import horizon.stream
Class ParticleFX
Field Emitter:ParticleEmitter[10]
Field LoopFX?
Field Running?
Method New()
For Local i:Int = 0 To 9
Emitter[i] = New ParticleEmitter
Next
LoopFX = False
Running = True
End
Function DuplicateFrom:ParticleFX(pfx:ParticleFX)
Local n:ParticleFX = New ParticleFX
n.LoopFX = pfx.LoopFX
n.Running = pfx.Running
For Local i:Int = 0 To 9
n.Emitter[i].X = pfx.Emitter[i].X
n.Emitter[i].Y = pfx.Emitter[i].Y
n.Emitter[i].EmitterDelay = pfx.Emitter[i].EmitterDelay
n.Emitter[i].EmitterDuration = pfx.Emitter[i].EmitterDuration
n.Emitter[i].EmissionRate = pfx.Emitter[i].EmissionRate
n.Emitter[i].EmissionEachFrame = pfx.Emitter[i].EmissionEachFrame
n.Emitter[i].Image = pfx.Emitter[i].Image
n.Emitter[i].SpeedX = pfx.Emitter[i].SpeedX
n.Emitter[i].SpeedY = pfx.Emitter[i].SpeedY
n.Emitter[i].SpeedVarX = pfx.Emitter[i].SpeedVarX
n.Emitter[i].SpeedVarY = pfx.Emitter[i].SpeedVarY
n.Emitter[i].LaunchSize = pfx.Emitter[i].LaunchSize
n.Emitter[i].SizeVar = pfx.Emitter[i].SizeVar
n.Emitter[i].Grow = pfx.Emitter[i].Grow
n.Emitter[i].MinSize = pfx.Emitter[i].MinSize
n.Emitter[i].MaxSize = pfx.Emitter[i].MaxSize
n.Emitter[i].Alpha = pfx.Emitter[i].Alpha
n.Emitter[i].AlphaVar = pfx.Emitter[i].AlphaVar
n.Emitter[i].AlphaChange = pfx.Emitter[i].AlphaChange
n.Emitter[i].RotationSpeed = pfx.Emitter[i].RotationSpeed
n.Emitter[i].RotationVar = pfx.Emitter[i].RotationVar
n.Emitter[i].RotationStart = pfx.Emitter[i].RotationStart
n.Emitter[i].ColorR = pfx.Emitter[i].ColorR
n.Emitter[i].ColorG = pfx.Emitter[i].ColorG
n.Emitter[i].ColorB = pfx.Emitter[i].ColorB
n.Emitter[i].ColorChangeR = pfx.Emitter[i].ColorChangeR
n.Emitter[i].ColorChangeG = pfx.Emitter[i].ColorChangeG
n.Emitter[i].ColorChangeB = pfx.Emitter[i].ColorChangeB
n.Emitter[i].StartOffsetX = pfx.Emitter[i].StartOffsetX
n.Emitter[i].StartOffsetY = pfx.Emitter[i].StartOffsetY
n.Emitter[i].StartOffsetVarX = pfx.Emitter[i].StartOffsetVarX
n.Emitter[i].StartOffsetVarY = pfx.Emitter[i].StartOffsetVarY
n.Emitter[i].GravityX = pfx.Emitter[i].GravityX
n.Emitter[i].GravityY = pfx.Emitter[i].GravityY
n.Emitter[i].LifeTime = pfx.Emitter[i].LifeTime
n.Emitter[i].RenderType = pfx.Emitter[i].RenderType
Next
Return n
End
Method SetLoop(t?)
LoopFX = t
End
Method MoveTo(x#, y#)
For Local i:Int = 0 To 9
Emitter[i].x = x
Emitter[i].y = y
Next
End
Method Render(delta# = 1.0, LaunchNewParticles?=True)
Local a# = GetAlpha()
Local sx#, sy#
If Running
For Local i:Int = 0 To 9
Emitter[i].Render(delta,LaunchNewParticles)
If LoopFX
Emitter[i].Loop()
End
Next
End
SetAlpha(a)
SetColor(255,255,255)
End
Method Finished?()
Local count:Int = 0
For Local i:Int = 0 To 9
If Emitter[i].Finished() Or Emitter[i].RenderType = ParticleEmitter.RENDER_OFF Then count+=1
Next
If count>9 Then Return True Else Return False
End
Function Load:ParticleFX(Filename:String, Loop? = False)
Local t:ParticleFX = New ParticleFX
t.LoadFX(Filename)
t.LoopFX = Loop
Return t
End
Method Stop()
Running = False
End
Method Restart()
For Local i:Int = 0 To 9
Emitter[i].frame = 0
Next
Running = True
End
Method Reset()
For Local i:Int = 0 To 9
Emitter[i].Reset()
Next
End
Method LoadFX (Filename:String)
Local f:Stream = New Stream(Filename)
If (f)
For Local i:Int = 0 To 9
Emitter[i].EmitterDelay = f.ReadFloat()
Emitter[i].EmitterDuration = f.ReadFloat()
Emitter[i].EmissionRate = f.ReadFloat()
Emitter[i].EmissionEachFrame = f.ReadFloat()
Emitter[i].SpeedX = f.ReadFloat()
Emitter[i].SpeedY = f.ReadFloat()
Emitter[i].SpeedVarX = f.ReadFloat()
Emitter[i].SpeedVarY = f.ReadFloat()
Emitter[i].SizeVar = f.ReadFloat()
Emitter[i].LaunchSize = f.ReadFloat()
Emitter[i].Grow = f.ReadFloat()
Emitter[i].MinSize = f.ReadFloat()
Emitter[i].MaxSize = f.ReadFloat()
Emitter[i].Alpha = f.ReadFloat()
Emitter[i].AlphaVar = f.ReadFloat()
Emitter[i].AlphaChange = f.ReadFloat()
Emitter[i].RotationSpeed = f.ReadFloat()
Emitter[i].RotationVar = f.ReadFloat()
Emitter[i].RotationStart = f.ReadFloat()
Emitter[i].StartOffsetX = f.ReadFloat()
Emitter[i].StartOffsetY = f.ReadFloat()
Emitter[i].StartOffsetVarX = f.ReadFloat()
Emitter[i].StartOffsetVarY = f.ReadFloat()
Emitter[i].ColorChangeR = f.ReadFloat()
Emitter[i].ColorChangeG = f.ReadFloat()
Emitter[i].ColorChangeB = f.ReadFloat()
Emitter[i].LifeTime = f.ReadFloat()
Emitter[i].RenderType = f.ReadInt()
Emitter[i].Image = f.ReadInt()
Emitter[i].ColorR = f.ReadFloat()
Emitter[i].ColorG = f.ReadFloat()
Emitter[i].ColorB = f.ReadFloat()
Emitter[i].gravityX = f.ReadFloat()
Emitter[i].gravityY = f.ReadFloat()
Next
f.Close()
Else
Error "Could not load Particle FX"
End If
End
End