Public
Const MAX_SMALL_EXPLOSIONS
As Long = 15
Public
SmallExplosion(1 To MAX_SMALL_EXPLOSIONS)
As TEffect
Public
SmallExploCount
As Long
Public
Const MAX_WAVE_EXPLOSIONS
As Long = 5
Public
ExplosionWave(1 To MAX_WAVE_EXPLOSIONS)
As TEffect
Public
WaveExploCount
As Long
Public
Const MAX_BIG_EXPLOSIONS
As Long = 10
Public
BigExplosion(1 To MAX_BIG_EXPLOSIONS)
As TEffect
Public
BigExploCount
As Long
Public
Const MAX_TAIL_EXPLOSIONS
As Long = 10
Public
TailExplosion(1 To MAX_TAIL_EXPLOSIONS)
As TEffect
Public
TailExploCount
As Long
Public
Respawn
As TEffect
Public
Fire
As TEffect
Public
Smoke
As TEffect
Public
EffectTexture(1 To 2)
As DirectDrawSurface7
Public
Sub InitExamples()
Dim n As Long
For n = 1 To 2
CreateTexture g_App.Path_Pics &
"\effect" & Format(n, "00") & ".bmp",
EffectTexture(n)
Next n
For n = 1 To MAX_SMALL_EXPLOSIONS
With SmallExplosion(n)
.ParticleCount = 30
ReDim .Particle(1 To
.ParticleCount)
.SpreadRange = PI * 2
.SpreadRangeOffset = 0
.StartMinRadius = 0
.EndRadius = 20
.VDeceleration = 1
.ColorMode = START_AND_INV_COLOR
.StartColor = SetColor(50, 100,
25)
.InvColor = SetColor(210, 210,
210)
.AttenuationStartRange = 0.3
.AttenuationSpeed = 0.01
.MinParticleRadius = 0.2
.MaxParticleRadius = 1.2
.MinParticleRot = -0.1
.MaxParticleRot = 0.1
End With
Next n
For n = 1 To MAX_WAVE_EXPLOSIONS
With ExplosionWave(n)
.ParticleCount = 500
ReDim .Particle(1 To
.ParticleCount)
.SpreadRange = PI * 2
.SpreadRangeOffset = 0
.StartMinRadius = 0
.EndRadius = 300
.VDeceleration = 0.97
.VDecelThreshold = 0.4
.ColorMode = ONLY_START_COLOR
.StartColor = SetColor(100, 120, 200)
.AttenuationStartRange = 0.3
.AttenuationSpeed = 0.004
.MinParticleRadius = 0.3
.MaxParticleRadius = 1
.MinParticleRot = -0.1
.MaxParticleRot = 0.1
End With
Next n
For n = 1 To MAX_BIG_EXPLOSIONS
With BigExplosion(n)
.ParticleCount = 300
ReDim .Particle(1 To
.ParticleCount)
.SpreadRange = PI * 2
.SpreadRangeOffset = 0
.StartMinRadius = -20
.EndRadius = 150
.VDivIncreasing = True
.VMaxIncreasing = 3
.VMinIncreasing = 0.2
.VDeceleration = 0.95
.VDecelThreshold = 0.35
.ColorMode = ONLY_START_COLOR
.StartColor = SetColor(200, 150,
100)
.AttenuationStartRange = 0.3
.AttenuationSpeed = 0.01
.MinParticleRadius = 0.3
.MaxParticleRadius = 1.3
End With
Next n
For n = 1 To MAX_TAIL_EXPLOSIONS
With TailExplosion(n)
.ParticleCount = 200
ReDim .Particle(1 To
.ParticleCount)
.SpreadRange = PI * 2
.SpreadRangeOffset = 0
.StartMinRadius = 0
.EndRadius = 10
.VDeceleration = 0.95
.VDecelThreshold = 0.35
.ColorMode = ONLY_START_COLOR
.StartColor = SetColor(200, 150,
100)
.AttenuationStartRange = 0.3
.AttenuationSpeed = 0.01
.MinParticleRadius = 0.3
.MaxParticleRadius = 1
.VelX = Cos(Rnd * PI * 2) * 10
.VelY = Sin(Rnd * PI * 2) * 10
.AccY = 0.2
End With
Next n
With Respawn
.ParticleCount = 100
ReDim .Particle(1 To .ParticleCount)
.SpreadRange = PI * 2
.SpreadRangeOffset = 0
.StartMinRadius = 0
.StartMaxRadius = 50
.EndRadius = -100
.VDeceleration = 1
.ColorMode = ONLY_START_COLOR
.StartColor = SetColor(255, 255, 255)
.AttenuationStartRange = 0.3
.AttenuationSpeed = 0.01
.AttenuationExpMode = True
.MinParticleRadius = 0.3
.MaxParticleRadius = 0.7
End With
With Fire
.ParticleCount = 500
ReDim .Particle(1 To .ParticleCount)
.SpreadRange = PI / 4
.SpreadRangeOffset = 3 * HPI -
.SpreadRange / 2
.StartMinRadius = 0
.EndRadius = 150
.VDeceleration = 0.9
.VDecelThreshold = 0.3
.ColorMode = ONLY_START_COLOR
.StartColor = SetColor(200, 150, 100)
.AttenuationStartRange = 0.3
.AttenuationSpeed = 0.01
.MinParticleRadius = 0.3
.MaxParticleRadius = 0.8
.InfiniteSpread = True
End With
With Smoke
.ParticleCount = 200
ReDim .Particle(1 To .ParticleCount)
.SpreadRange = 0.5
.SpreadRangeOffset = HPI -
.SpreadRange / 2
.StartMinRadius = 0
.EndRadius = 1000
.VDeceleration = 1
.ColorMode = ONLY_START_COLOR
.StartColor = SetColor(110, 110, 100)
.AttenuationStartRange = 0.1
.AttenuationSpeed = 0.001
.MinParticleRadius = 0.5
.MaxParticleRadius = 1.5
.InfiniteSpread = True
.MinParticleRot = -0.1
.MaxParticleRot = 0.1
End With
End Sub
Public
Sub DrawMyEffects()
SetCam
For n = 1 To MAX_SMALL_EXPLOSIONS
If SmallExplosion(n).Draw Then
DrawEffect SmallExplosion(n),
EffectTexture(1)
End If
Next n
For n = 1 To MAX_WAVE_EXPLOSIONS
If ExplosionWave(n).Draw Then
DrawEffect ExplosionWave(n),
EffectTexture(2)
End If
Next n
For n = 1 To MAX_BIG_EXPLOSIONS
If BigExplosion(n).Draw Then
DrawEffect BigExplosion(n),
EffectTexture(1)
End If
Next n
If Respawn.Draw Then
DrawEffect Respawn, EffectTexture(1)
End If
If Fire.Draw Then
DrawEffect Fire, EffectTexture(1)
End If
If Smoke.Draw Then
DrawEffect Smoke, EffectTexture(2)
End If
For n = 1 To MAX_TAIL_EXPLOSIONS
If TailExplosion(n).Draw Then
DrawEffect TailExplosion(n),
EffectTexture(1)
End If
Next n
End Sub
Private
Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Then SetEffect
Respawn, CSng(g_MouseX), CSng(g_MouseY)
If KeyCode = vbKeyA Then
TailExploCount = TailExploCount + 1
If TailExploCount >
MAX_TAIL_EXPLOSIONS Then TailExploCount = 1
SetEffect
TailExplosion(TailExploCount), CSng(g_MouseX), CSng(g_MouseY)
End If
If KeyCode = vbKeyT Then
SmallExploCount = SmallExploCount + 1
If SmallExploCount >
MAX_SMALL_EXPLOSIONS Then SmallExploCount = 1
If IsEffectInRect(g_Map.Wnd,
SmallExplosion(SmallExploCount), CSng(g_MouseX), CSng(g_MouseY)) Then
SetEffect
SmallExplosion(SmallExploCount), CSng(g_MouseX), CSng(g_MouseY)
End If
End If
If KeyCode = vbKeyControl Then
If Fire.Draw Then
Fire.Draw = False
Else
SetEffect Fire,
CSng(g_MouseX), CSng(g_MouseY)
End If
End If
If KeyCode = vbKeyShift Then
Fire.InfiniteSpread = Not
Fire.InfiniteSpread
End If
If KeyCode = vbKeyN Then
If Smoke.Draw Then
Smoke.Draw = False
Else
SetEffect Smoke,
CSng(g_MouseX), CSng(g_MouseY)
End If
End If
If KeyCode = vbKeyM Then
Smoke.InfiniteSpread = Not
Smoke.InfiniteSpread
End If
If KeyCode = vbKeyW Then
WaveExploCount = WaveExploCount + 1
If WaveExploCount >
MAX_WAVE_EXPLOSIONS Then WaveExploCount = 1
SetEffect
ExplosionWave(WaveExploCount), CSng(g_MouseX), CSng(g_MouseY)
End If
If KeyCode = vbKeyB Then
BigExploCount = BigExploCount + 1
If BigExploCount >
MAX_BIG_EXPLOSIONS Then BigExploCount = 1
SetEffect
BigExplosion(BigExploCount), CSng(g_MouseX), CSng(g_MouseY)
End If
End Sub
Private
Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As
Single)
g_MouseX = X
g_MouseY = Y
Fire.X = X
Fire.Y = Y
Smoke.X = X
Smoke.Y = Y
End Sub
|