March 04, 2021, 12:40:13 AM
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
»
Graphics
»
[bb] Simple particle engine by Andres [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Simple particle engine by Andres [ 1+ years ago ] (Read 644 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Simple particle engine by Andres [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:42 AM »
Title :
Simple particle engine
Author :
Andres
Posted :
1+ years ago
Description :
image% - either singleframed or multiframed image handle
x#, y# - location of the particle
xs#, ys# - velocity of the particle
duration% - duration of the particle in millisecs
frames% - if does then how many frames particle has (default: 1 frame)
Global Inerts# - Will be multiplied with velocity in every update
Code :
Code: BlitzBasic
Type
particle
Field
image%, x#, y#, xs#, ys#, w%, h%, time%, duration%, frames%
End Type
Global
Inerts# = .9
Function
CreateParticle
(
image%, x#, y#, xs#, ys#, duration%, frames% =
1
)
this.particle =
New
particle
thisimage% =
CopyImage
(
image%
)
thisx# = x#
thisy# = y#
thisxs# = xs#
thisys# = ys#
thisw% =
ImageWidth
(
thisimage%
)
thish% =
ImageHeight
(
thisimage%
)
this ime% =
MilliSecs
(
)
thisduration% = duration%
thisframes% = frames%
End Function
Function
DrawParticles
(
)
For
par.particle =
Each
particle
If
parframes% =
1
DrawImage
parimage%, parx% - parw% /
2
, pary% - parh% /
2
Else
frame% =
(
parframes% -
1
)
*
(
Float
(
MilliSecs
(
)
- par ime%
)
/ parduration%
)
If
frame% > parframes%
Then
frame% = parframes%
DrawImage
parimage%, parx% - parw% /
2
, pary% - parh% /
2
, frame%
EndIf
Next
End Function
Function
UpdateParticles
(
)
For
par.particle =
Each
particle
If
MilliSecs
(
)
- par ime% < parduration%
Then
parx# = parx# + parxs#
pary# = pary# + parys#
parxs# = parxs# * Inerts#
parys# = parys# * Inerts#
Else
FreeImage
parimage%
Delete
par
EndIf
Next
End Function
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Simple particle engine by Andres [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal