Amon, lots of stuff to change but I'm having loads of trouble getting my head around it as well.
This code 'runs' but doesn't do much...
Changes...
Global particle_list:TList moved into the Particle type definition.
If particle_list = Null particle_list = CreateList() added to the create function.
list.addlast particle,partical_list changed to particle_list.addlast(p) (and partical changed to particle)
p.particle = Null in destroy method changed to
p:particle = Null
Return from destroy method commented out (couldn't get it to work).
p.create() changed to particle.create() as the function belongs to the type and not the instances.
Following used to call draw() and update()
Draw and update changed to remove the for loops and the unnecessary ID...
Hope it helps.
<edit> ...and I reserve the right to have got this very wrong and missed a few changes I made. I think you used p.particle in some places when it should be p:particle.
This code 'runs' but doesn't do much...
Strict Graphics 1024,768,16,0 Global particle_count:Int = 0 SetMaskColor 255,0,255 Global particles:TImage = LoadImage("particle.png",MASKEDIMAGE) Type particle Global particle_list:TList Field x:Int, y:Int, s:Int Function create() If particle_list = Null particle_list = CreateList() While particle_count = 0 For Local i:Int = 0 To 100 Local p:particle = New particle p.x = MouseX() p.y = MouseY() p.s = Rand(3,10) particle_list.addlast(p) If i:Int >=100 particle_count = 1 EndIf Next Wend End Function Method destroy(p:particle) For Local p:particle = EachIn particle_list If p.x >1026 Or p.x < -2 p:particle = Null EndIf If p.y > 770 Or p.y < -2 p:particle = Null EndIf Next ' Return p End Method Method update() x:+3 End Method Method draw() DrawImage particles,x,y,0 End Method End Type Repeat Cls particle.create() If particle.particle_list For Local p:particle = EachIn particle.particle_list Print p.x p.draw() Next EndIf Rem If particle.particle_list For Local p:particle = EachIn particle.particle_list p.update() Next EndIf End Rem Flip Until KeyHit(KEY_ESCAPE)
Changes...
Global particle_list:TList moved into the Particle type definition.
If particle_list = Null particle_list = CreateList() added to the create function.
list.addlast particle,partical_list changed to particle_list.addlast(p) (and partical changed to particle)
p.particle = Null in destroy method changed to
p:particle = Null
Return from destroy method commented out (couldn't get it to work).
p.create() changed to particle.create() as the function belongs to the type and not the instances.
Following used to call draw() and update()
If particle.particle_list For Local p:particle = EachIn particle.particle_list Print p.x p.draw() Next EndIf If particle.particle_list For Local p:particle = EachIn particle.particle_list p.update() Next EndIf
Draw and update changed to remove the for loops and the unnecessary ID...
Method update() Print "Update called" x:+3 End Method Method draw() Print "draw called" DrawImage particles,x,y,0 End Method
Hope it helps.
<edit> ...and I reserve the right to have got this very wrong and missed a few changes I made. I think you used p.particle in some places when it should be p:particle.