Beat by tonyg but a other techniques used here.
For example, using the New() method which gets called automatically when you do:
s:star=New star
For example, using the New() method which gets called automatically when you do:
s:star=New star
Rem Scrolling Starfield End Rem Framework BRL.Basic Import BRL.glmax2d Import BRL.pngloader Strict '---------------------------------------------------------- ' global variables Const X_RES = 800, Y_RES = 600 : Int Global star_list:Tlist = CreateList() '---------------------------------------------------------- ' define types Type star Field x,y,speed : Int Method New() ListAddLast star_list, Self x = Rand(10,X_RES-10) y = Rand(10,Y_RES-10) speed=1 End Method Function update_stars() For Local s:star=EachIn star_list s.y:+s.speed If s.y>Y_RES s.y=s.y-Y_RES Next End Function Function draw_stars() SetBlend SOLIDBLEND ; SetColor 255,255,255 For Local s:star = EachIn star_list If s.speed = 1 SetColor 255,255,255 Else If Rand(1,100)<50 SetColor 255,255,255 Else SetColor 128,128,128 EndIf EndIf Plot s.x,s.y Next End Function End Type '---------------------------------------------------------- Global s:star Graphics X_RES,Y_RES,32,0 HideMouse ' create 75 stars For Local n=1 To 75 s=New star If n <= 50 s.speed = 2 Next ' main loop Repeat Cls s.update_stars s.draw_stars FlushMem Flip Until KeyHit(KEY_ESCAPE) End