Problem with the OO side of things...

BlitzMax Forums/BlitzMax Beginners Area/Problem with the OO side of things...

I am having trouble getting my head around the OO side of things, I have ripped apart a tutorial in Wave's beginners guide and tried to adapt it to an 'explosion Object'.

This is the code I have, if any could let me know what I am doing wrong be appreciated.


Strict

Global explo:TList=New TList

Type Texplo

	Field x,y,f#,al#
	
	Method update()
		f=+0.25
		al=-0.05
		SetAlpha(al)
		DrawImage(myexplo,x,y,f)
	End Method
	
	Function createexplo:Texplo(xx,yy,ff)
		Local ex:Texplo=New Texplo
		ex.x=xx+Rnd(60)-30
		ex.y=yy+Rnd(40)-20
		ex.f#=ff
		ex.al#=1-(Rnd(20)/100)
		explo.AddLast ex
	End Function
	
End Type


Graphics 800,600,0
SetBlend( AlphaBlend )
SetMaskColor 0,0,0

Global myexplo:Timage=LoadAnimImage("explosion-001.png",128,128,0,16)

Local i
Repeat
	If MouseHit(1)
		For i=0 To 8
			Texplo.createexplo MouseX(),MouseY(),0			
		Next
	EndIf
	
	Local i=0
	For Local e:Texplo =EachIn explo
		e.Update
		i=+1
	Next
	Print i
	
	Flip;Cls
Until KeyDown(Key_Escape)


I bet the explostion image only has 8 frames

as in
	Function createexplo:Texplo(xx,yy,ff)
		Local ex:Texplo=New Texplo
		ex.x=xx+Rnd(60)-30
		ex.y=yy+Rnd(40)-20
		ex.f#=ff
		ex.al#=1-(Rnd(20)/100)
		explo.AddLast ex
		Return ex
	End Function


because it doesnt draw me explosions...?

@dream, no I changed my mind about return, cos you are keeping the objects ina tlist, so it doesnt matter. (I did delete the post within 1min of posting it)

But without the media, I cannot run it to see what it doesnt do. So ... next time when you post, say what it doesnt do so we can tell.

Anyway doesnt frame have to be a whple number?
Drawimage (x,x,NUMBER OF FRAME)

and
Texplo.createexplo MouseX(),MouseY(),I
maybe?

ok it is not drawing the image or even adding things to the list

when i run through this bit of code
	Local i=0
	For Local e:Texplo =EachIn explo
		e.Update
		i=+1
	Next
	Print i

it always prints 1
it should print 9 on one click 18 on the second mouseclick etc, it should make 9(0-8) new explosions each mouse click

then drawthem to the screen and animate through the 16 frames.....

it always prints 1....... cos you have i=+1 (that is let i equal 1)

ok i get that now i thought that was and incremental thing doh......i=i+1; GOT THAT SORTED.

i think i have it, how do you remove an item from the list say when

if f>16 then listremove


well you would remove the first Item added, so you could just
if f>16
    For Local e:Texplo =EachIn explo
        ListRemove( explo,e )
        Exit
    next
Endif
But normaly I would keep a copy of the link within the type, and use removeLink

i:+1

thanks for your help H&K appreciate your patience...;)