PixelWars with Types

Blitz3D Forums/Blitz3D Programming/PixelWars with Types

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

UPDATED TO VERSION 4
;Probewars with Types v4 

Type Probe 
Field X%,Y% 
Field health% 
Field r,g,b 
End Type 

For NR = 1 To 30 

P.Probe = New Probe 
;Possition 
P\X = Rnd(0,800): P\Y = Rnd(0,600) 
;Colors 
P\r = Rnd(0,255): P\g = Rnd(0,255): P\b = Rnd(0,255) 


Next 

Graphics 800,600,16,0 ;Window 
SetBuffer BackBuffer() 
SeedRnd = MilliSecs() 

While Not KeyDown(1) 
;Cls 

;Move the Probe randomly 
For P.Probe = Each Probe 

P\X = P\X + Rnd( -1,1 ) 
P\Y = P\Y + Rnd( -1,1 ) 

Color P\r,P\g,P\b ;add color 
Rect P\X,P\Y ,3,3
Next 

;Check if any Probe overlaps any other probe 
For P.Probe = Each Probe 
p2.probe = After p
While p2 <> Null
		If P\X = P2\X And P\Y = P2\Y 
		Delete P2
EndIf 
p2 = After p2
Wend
Next 

Flip :Cls
Wend