I found your problem. You were calling the recycle method for each star, but there's also a loop for each star in the method. So for 400 stars you were doing 120000 interations! I do also think your aliens are also suffering from a similar situation.
Just put a call to the recycle method inside the loop in the update function and remove it from your main loop.
Here's the changes I made:
Just put a call to the recycle method inside the loop in the update function and remove it from your main loop.
Here's the changes I made:
[code] Strict 'image made global within type: slight speed increase 'star list global within type: very lisght speed increase Const GR_WIDTH = 1024, GR_HEIGHT = 768, DEPTH = 16, HERTZ = 60 Graphics GR_WIDTH,GR_HEIGHT,DEPTH,HERTZ SetMaskColor 255,0,255 Type star Field xpos:Int Field ypos:Int Field speed:Int Global starImg:TImage Global starlist:TList Global num_stars Global max_stars Function create_star() num_stars = 0 max_stars = 500 starlist=CreateList() For Local x:Int = 0 To max_stars-1 Local s:star = New star ListAddLast starlist,(s) s.xpos = rnd(0,GR_WIDTH) s.ypos = Rand(-1,-GR_HEIGHT) s.speed = Rand(2,15) num_stars:+1 Next 'create star image SetColor 255,0,255 DrawRect(0,0,3,3) SetColor 255,255,255 Plot 1,0 Plot 0,1 Plot 1,1 Plot 2,1 Plot 1,2 starImg=CreateImage(3,3) GrabImage(starImg,0,0) End Function Function update_stars() For Local s:star = EachIn starlist s.ypos:+s.speed s.recycle_star() s.draw_star() Next End Function Method draw_star() DrawImage starImg,xpos,ypos,0 End Method Method recycle_star() If ypos > GR_HEIGHT Then ypos = -1 End Method End Type Const TARGET:Int=60 Local frames:Int=0 star.create_star() Local frameTime:Int Local totalTime:Int=0 Local tCounter:Int=0 Repeat frameTime=MilliSecs() Cls SetColor 255,255,255 star.update_stars() DrawRect 0,0,160,28 SetColor 0,0,0 DrawText TARGET+" Frames:"+totalTime+"ms",0,12 DrawText "Stars:"+star.num_stars,0,0 tCounter:+(MilliSecs()-frameTime) If frames=TARGET Then totalTime=tCounter frames=0 tCounter=0 Else frames:+1 EndIf FlushMem Flip Until KeyHit(KEY_ESCAPE)