' It's all a bit rolly ' Global MASSSIZE:Int=4 Global MASSRAD:Int=MASSSIZE/2 Type TMass Field x:Float Field y:Float Field v:TVector Field r:Int Field g:Int Field b:Int Field mass:Float Field friend:Int Field inverse:Int Method New() v=TVector.Create() x=Rnd(0,GraphicsWidth()) y=Rnd(0,GraphicsWidth()) r=255 g=255 b=255 mass=25 friend=True inverse=False End Method Method Attract(o:TMass) If o=Self Return EndIf Local d:TVector=TVector.Create(o.x-x,o.y-y) Local l:Float=d.Length() If l>0.1 l:*l d.Normalise() d.Scale((1/l)*o.mass) If o.inverse d.Minus() EndIf v.Add(d) If d.Length()>MASSSIZE d.SetLength(MASSSIZE) EndIf EndIf End Method Method MoveAndDraw() x:+v.x y:+v.y SetColor(r,g,b) DrawOval(x-MASSRAD,y-MASSRAD,MASSSIZE,MASSSIZE) End Method End Type Type TPoint Field x:Float Field y:Float Field v:TVector Field r:Int Field g:Int Field b:Int Field dead:Int Field lost:Int Method New() v=TVector.Create() x=Rnd(0,GraphicsWidth()) y=Rnd(0,GraphicsWidth()) r=Rand(100,200) g=Rand(100,200) b=Rand(100,200) dead=False lost=False End Method Method Attract:Int(o:TMass) If dead Or lost Return EndIf Local d:TVector=TVector.Create(o.x-x,o.y-y) Local l:Float=d.Length() If lMASSSIZE d.SetLength(MASSSIZE) EndIf EndIf Return dead End Method Method MoveAndDraw() If (Not dead) And (Not lost) x:+v.x y:+v.y SetColor(r,g,b) Plot(x,y) If x<0 Or y<0 Or x>GraphicsWidth() Or y>GraphicsHeight() lost=True EndIf EndIf End Method End Type