From 991c2de75c4d8d78e135d38eae2dfbd09ac0573a Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 29 Nov 2005 20:35:03 +0000 Subject: Implementing new special block code --- particle.bmx | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) (limited to 'particle.bmx') diff --git a/particle.bmx b/particle.bmx index 6269381..6eba5d3 100644 --- a/particle.bmx +++ b/particle.bmx @@ -17,7 +17,7 @@ Type TParticle Field dy:Double Field ai:Double Field s:Double - Field si:double + Field si:Double Function Dust:TParticle(x:Int, y:Int) Local o:TParticle=New TParticle @@ -98,3 +98,106 @@ Type Particles SetScale(1,1) End Function End Type + +Type TTextParticle + Field txt:String + Field x:Double + Field y:Double + Field a:Double + Field dx:Double + Field dy:Double + Field ai:Double + Field s:Double + Field si:Double + Field r:Int + Field g:Int + Field b:Int + Field fnt:TBitmapFont + + Function Create:TTextParticle(fnt:TBitmapFont, txt:String, x:Double, y:Double, dx:Double, dy:Double, r:Int, g:Int, b:Int, a:Double, ai:Double, s:Double, si:Double) + Local o:TTextParticle=New TTextParticle + + If x=-1 + x=GraphicsWidth()/2 + EndIf + + o.x=x + o.y=y + o.a=a + o.ai=ai + o.dx=dx + o.dy=dy + o.s=s + o.si=si + o.txt=txt + o.r=r + o.g=g + o.b=b + o.fnt=fnt + Return o + End Function + + Method Update:Int() + SetAlpha(a) + SetScale(s,s) + fnt.CentreOn(txt,x,y,r,g,b) + x:+dx + y:+dy + a:+ai + s:+si + Return a>0 + End Method +End Type + +Type TextParticles + Global plist:TList + Global sy:Int + Const sx:Int=646 + + Function Init() + plist=CreateList() + sy=300 + End Function + + Function Clear() + plist.Clear() + sy=300 + End Function + + Function Big(txt:String, r:Int, g:Int, b:Int) + plist.AddLast(TTextParticle.Create(GameGFX.font,txt,-1,GraphicsHeight()-GameGFX.font.MaxHeight()/2,0,0,r,g,b,1,-0.01,1,0)) + plist.AddLast(TTextParticle.Create(GameGFX.font,txt,-1,GraphicsHeight()-GameGFX.font.MaxHeight()/2,0,0,r,g,b,1,-0.02,1,0.1)) + End Function + + Function Score(txt:String) + Local r:Int=Rand(128,255) + Local g:Int=Rand(128,255) + Local b:Int=Rand(128,255) + + plist.AddLast(TTextParticle.Create(GameGFX.font,txt,sx,sy,0,0,r,g,b,1,-0.01,1,0)) + plist.AddLast(TTextParticle.Create(GameGFX.font,txt,sx,sy,0,0,r,g,b,1,-0.02,1,0.1)) + + sy:+GameGFX.font.MaxHeight() + + If sy>GraphicsHeight()-20 + sy=300 + EndIf + End Function + + Function Draw() + Local l:TEasyLink=TEasyLink.Create(plist) + + While l.Value() + Local p:TTextParticle=TTextParticle(l.Value()) + + If (p.Update()) + l.MoveNext() + Else + l.Remove() + EndIf + Wend + SetColor(255,255,255) + SetAlpha(1) + SetScale(1,1) + End Function +End Type -- cgit v1.2.3