summaryrefslogtreecommitdiff
path: root/particle.bmx
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2006-04-25 23:45:01 +0000
committerIan C <ianc@noddybox.co.uk>2006-04-25 23:45:01 +0000
commitc93d5990b230175597557978d0bc2c094bee3bdb (patch)
tree31aedf971660b7db1e8338531e577d140a425766 /particle.bmx
parent0c54a57c59fdce1ffc0055f57983ad090a3e18e6 (diff)
Initial working version
Diffstat (limited to 'particle.bmx')
-rw-r--r--particle.bmx53
1 files changed, 35 insertions, 18 deletions
diff --git a/particle.bmx b/particle.bmx
index 4098598..e511ace 100644
--- a/particle.bmx
+++ b/particle.bmx
@@ -21,9 +21,7 @@
' $Id$
'
Strict
-Import noddybox.algorithm
Import "global.bmx"
-Import "gametypes.bmx"
Type TParticle
Field life:Int
@@ -36,40 +34,50 @@ Type TParticle
Field ai:Double
Field s:Double
Field si:Double
+ Field r:Int
+ Field g:Int
+ Field b:Int
- Function Image:TParticle(i:TImage, x:Int, y:Int)
+ Function Image:TParticle(i:TImage, x:Double, y:Double, dx:Double, dy:Double, r:Int, g:Int, b:Int)
Local o:TParticle=New TParticle
o.life=120
o.x=x
o.y=y
o.a=1
o.ai=-0.01
- o.dx=0
- o.dy=0
+ o.dx=dx
+ o.dy=dy
o.s=1
o.si=0
o.i=i
+ o.r=r
+ o.g=g
+ o.b=b
Return o
End Function
- Function ScaleImage:TParticle(i:TImage, x:Int, y:Int,si:Double)
+ Function ScaleImage:TParticle(i:TImage, x:Double, y:Double, dx:Double, dy:Double, si:Double, r:Int, g:Int, b:Int)
Local o:TParticle=New TParticle
o.life=120
o.x=x
o.y=y
o.a=1
o.ai=-0.01
- o.dx=0
- o.dy=0
+ o.dx=dx
+ o.dy=dy
o.s=1
o.si=si
o.i=i
+ o.r=r
+ o.g=g
+ o.b=b
Return o
End Function
Method Update:Int()
SetAlpha(a)
SetScale(s,s)
+ SetColor(r,g,b)
DrawImage(i,x,y)
x:+dx
y:+dy
@@ -91,20 +99,28 @@ Type Particles
plist.Clear()
End Function
- Function AddImage(i:TImage, x:Int, y:Int)
- If plist.Count()<1000
- plist.AddLast(TParticle.Image(i,x,y))
- EndIf
+ Function AddImage(i:TImage, x:Double, y:Double, dx:Double=0, dy:Double=0)
+ plist.AddLast(TParticle.Image(i,x,y,dx,dy,255,255,255))
End Function
- Function AddScaledImage(i:TImage, x:Int, y:Int, si:Double=0.1)
- If plist.Count()<1000
- plist.AddLast(TParticle.ScaleImage(i,x,y,si))
- EndIf
+ Function AddScaledImage(i:TImage, x:Double, y:Double, si:Double=0.1, dx:Double=0, dy:Double=0)
+ plist.AddLast(TParticle.ScaleImage(i,x,y,dx,dy,si,255,255,255))
+ End Function
+
+ Function AddExplosion(x:Double, y:Double)
+ For Local f:Int=0 To 20
+ plist.AddLast(TParticle.Image(GFX.star,x,y,Rnd(-2,2),Rnd(-2,2),Rand(100,255),Rand(100,255),Rand(100,255)))
+ Next
+ End Function
+
+ Function AddBigExplosion(x:Double, y:Double)
+ plist.AddLast(TParticle.ScaleImage(GFX.exhaust,x,y,0,0,0.3,255,0,0))
+ For Local f:Int=0 To 50
+ plist.AddLast(TParticle.Image(GFX.star,x,y,Rnd(-2,2),Rnd(-2,2),Rand(100,255),Rand(100,255),Rand(100,255)))
+ Next
End Function
Function Draw()
- SetColor(255,255,255)
Local l:TEasyLink=TEasyLink.Create(plist)
While l.Value()
@@ -118,5 +134,6 @@ Type Particles
Wend
SetAlpha(1)
SetScale(1,1)
+ SetColor(255,255,255)
End Function
-End Type
+End Type \ No newline at end of file