March 08, 2021, 04:15:59 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Effects
»
[bb] Firework Effect by Xzider [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Firework Effect by Xzider [ 1+ years ago ] (Read 885 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Firework Effect by Xzider [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:38 AM »
Title :
Firework Effect
Author :
Xzider
Posted :
1+ years ago
Description :
Short test with particles, kind of looks like fireworks, might help some one. You will need 2 images for the sparks, just name then Spark1.bmp and Spark2.bmp
Code :
Code: BlitzBasic
Graphics3D
800
,
600
,
32
,
2
Global
Temp_ParticleID%
Global
Dir%
Global
Camera% =
CreateCamera
(
)
Type
Particle
Field
Entity%
Field
TexName$
Field
ID%
Field
ParticleType%
Field
X#
Field
Y#
Field
Z#
Field
Scale0%
Field
Scale1%
Field
Alpha#
Field
Counter0%
Field
Counter1%
Field
AlphaCounter0%
Field
AlphaCounter1%
Field
Color0%
Field
Color1%
Field
Color2%
Field
Dir#
Field
Dir1#
Field
Dir2#
Field
Dir3#
Field
Gravity#
End Type
While
Not
KeyHit
(
1
)
If
Rand
(
20
)
=
1
X# =
Rand
(
-
100
,
100
)
Y# =
Rand
(
-
100
,
100
)
Z# =
Rand
(
100
,
250
)
For
i=
1
To
10
Create_Particle
(
"Spark1.bmp"
,X#,Y#,Z#,
1
,
1
,
1
,
1
,
255
,
255
,
255
,
1000
)
Create_Particle
(
"Spark2.bmp"
,X#,Y#,Z#,
1
,
1
,
1
,
1
,
255
,
255
,
255
,
1000
)
Next
End If
Cls
UpdateWorld
RenderWorld
Update_Particles
(
)
Flip
Wend
Function
Create_Particle
(
TempName$,TempX#,TempY#,TempZ#,TempAlpha#,TempType%,TempScale0%,TempScale1%,TempColor0%,TempColor1%,TempColor2%,TempCounter%
)
Pa.Particle =
New
Particle
PaTexName$ = TempName$
PaX# = TempX#
PaY# = TempY#
Paz# = TempZ#
PaAlpha# = TempAlpha#
PaParticleType% = TempType%
PaScale0% = TempScale0%
PaScale1% = TempScale1%
PaCounter0% =
MilliSecs
(
)
PaCounter1% = TempCounter%
PaAlphacounter0% =
MilliSecs
(
)
PaAlphaCounter1% =
50
PaColor0% = TempColor0%
PaColor1% = TempColor1%
PaColor2% = TempColor2%
SeedRnd
MilliSecs
(
)
PaDir1# =
Rand
(
-
1
,
1
)
PaDir2# =
Rand
(
-
1
,
1
)
PaDir3# =
Rand
(
-
1
,
1
)
If
Dir% =
1
Dir% =
2
Else
Dir% =
1
End If
PaDir# = Dir%
PaEntity% =
LoadSprite
(
PaTexName$
)
ScaleSprite
PaEntity%,PaScale0%,PaScale1%
EntityAlpha
PaEntity%,PaAlpha#
PositionEntity
PaEntity%,PaX#,PaY#,Pa#
If
PaColor0% =
0
And
PaColor1% =
0
And
PaColor2% =
0
Else
EntityColor
PaEntity%,PaColor0%,PaColor1%,PaColor2%
End If
If
Not
PaEntity%
RuntimeError
"Could not load sprite "
+ PaTexName$ +
"!"
End If
End Function
Function
Update_Particles
(
)
For
Pa.Particle =
Each
Particle
Select
PaParticleType%
Case
1
PaAlpha# = PaAlpha# -
0.01
EntityAlpha
PaEntity%,PaAlpha#
MoveEntity
PaEntity%,PaDir1#,PaDir2#,PaDir3#
MoveEntity
PaEntity%,
0
,PaGravity#,
0
PaGravity# = PaGravity# -
0.05
Default
End Select
If
MilliSecs
(
)
> PaAlphaCounter0% + PaAlphaCounter1%
PaAlphaCounter0% =
MilliSecs
(
)
End If
If
MilliSecs
(
)
> PaCounter0% + PaCounter1%
Or
PaAlpha# <=
0
FreeEntity
PaEntity%
Delete
Pa.Particle
End If
Next
End Function
Function
DeleteParticles
(
)
For
Pa.Particle =
Each
Particle
FreeEntity
PaEntity%
Delete
Pa.Particle
Next
End Function
Function
New_ParticleID
(
)
Temp_ParticleID% = Temp_ParticleID% +
1
End Function
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Effects
»
[bb] Firework Effect by Xzider [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal