Graphics3D 800,600,32,2
SetBuffer BackBuffer()
SeedRnd MilliSecs()
light=CreateLight()
cam=CreateCamera()
MoveEntity cam,0,0,-30
Type cube
Field scale#
Field cube
Field work
Field life
Field x#
Field y#
Field col1
Field col2
Field col3
End Type
Function nCreateCube()
c.cube = New cube
c\scale = Rnd(.5,1.4)
c\cube=CreateCube()
c\work=1
c\life=100
c\x=Rnd(-20,20)
c\y=Rnd(-20,20)
c\col1=Rnd(255)
c\col2=Rnd(255)
c\col3=Rnd(255)
ScaleEntity c\cube,c\scale,c\scale,c\scale
EntityColor c\cube,c\col1,c\col2,c\col3
PositionEntity c\cube,c\x,c\y,0
EntityPickMode c\cube,1
End Function
Repeat
If MouseHit(1)
pick=CameraPick(cam,MouseX(),MouseY())
ent = pick
For c.cube = Each cube
If pick=c\cube
EntityColor c\cube,255,0,0
c\work=0
EndIf
Next
EndIf
For c.cube = Each cube
If c\work=0
c\life=c\life-1
If c\life=<0
FreeEntity c\cube
Delete c
EndIf
EndIf
Next
If KeyHit(57)
For cik=1 To 5
ncreatecube()
Next
EndIf
UpdateWorld
RenderWorld
Text 20,20,pick
Flip
Until KeyHit(1)
End