Const cellsize=10 Const gwidth=1280 Const gheight=720 Type TTower Global towers:TList=New TList Field x#,y#,size# Field vx#,vy# Field team:TTeam Function Create:TTower(x#,y#,size#,team:TTeam) t:ttower=New ttower t.x=x t.y=y t.size=size t.team=team towers.addlast t Return t End Function Method update() 'size:+Rnd(-1,1)*.1'*Sqr(size) For t:tteam=EachIn teams For tower:ttower=EachIn t.towers If tower<>Self dx#=tower.x-x dy#=tower.y-y d#=dx*dx+dy*dy d=Max(0,Min(1,d)) dx:*.0001/d dy:*.0001/d If t=team vx:-dx*.99 vy:-dy*.99 Else vx:+dx/(teams.count()-1) vy:+dy/(teams.count()-1) EndIf EndIf Next Next vx:-(x-gwidth/2)*.0001 vy:-(y-gheight/2)*.0001 vx:+Rnd(-1,1)*.1 vy:+Rnd(-1,1)*.1 vx:*.999 vy:*.999 x:+vx y:+vy End Method Method draw() SetColor 255-team.r,255-team.g,255-team.b ' DrawOval x-5,y-5,10,10 End Method End Type Type TTeam Field r#,g#,b# Field towers:TList Method New() teams.addlast Self Select teams.count() Case 1 r=255 Case 2 g=255 Case 3 b=255 End Select towers=New TList For c=1 To 4 towers.addlast ttower.Create(Rnd(gwidth),Rnd(gheight),Rnd(3,5),Self) Next End Method Method update() For t:ttower=EachIn towers t.update Next End Method Method draw() For t:ttower=EachIn towers t.draw Next End Method End Type Global xcells = gwidth/cellsize Global ycells = gheight/cellsize Global power#[xcells, ycells] Global owner:tteam[xcells,ycells] Function calcPower() For x=0 To xcells-1 For y=0 To ycells-1 Local px# = (x+.5)*cellsize Local py# = (y+.5)*cellsize Local maxpower#=-1 Local bigteam:tteam=Null For team:tteam=EachIn teams Local tpower#=0 For tower:ttower=EachIn team.towers Local dx# = px-tower.x Local dy# = py-tower.y d#=dx*dx+dy*dy tpower:+tower.size/d Next If tpower