
Graphics3D 800,600,0,2
SetBuffer BackBuffer() : SeedRnd (MilliSecs())
;типы колизий
Const TypeMegaBonus = 1
Const TypePoint = 2
;обьявляю тип для кубиков
Type TMegaCube
Field cub
End Type
Global point = CreateCube()
EntityType point,TypePoint
Global cam = CreateCamera(point)
PositionEntity cam, 0, 10, -15
;создаем 20 мега кубиков
pos=0
For i=1 To 20
pos=pos+15
c.TMegaCube = New TMegaCube
c\cub = CreateCube()
EntityType c\cub,TypeMegaBonus
EntityColor c\cub,Rand(0,255), Rand(0,255), Rand(0,255)
PositionEntity c\cub,Rand(-20,20),0,pos
Next
Collisions TypePoint,TypeMegaBonus,2,3
;ОСНОВНОЙ ЦИКЛ
While Not KeyDown(1)
PointEntity cam,point
UpdateMove ()
coll = EntityCollided (point,TypeMegaBonus)
If coll Then ;с чем то столкнулись...перебираем список на совпадение "хендлов", и херим нужный
For c.TMegaCube = Each TMegaCube
If coll=c\cub Then
FreeEntity c\cub : Delete c
Exit ;уже нашли нужный останавливаем перебор зачем нам перебирать другие?
EndIf
Next
EndIf
UpdateWorld ()
RenderWorld ()
Flip
Delay 25
Wend
End
;ФУНКЦИИ
Function UpdateMove ()
If KeyDown(200) Then MoveEntity point,0,0,1
If KeyDown(208) Then MoveEntity point,0,0,-1
If KeyDown(203) Then TurnEntity point,0,1.5,0
If KeyDown(205) Then TurnEntity point,0,-1.5,0
End Function
держи...примерно так. можно еще вогнать кубики в массив, смотри как тебе удобней.
Есть кстати способ уйти от полного перебора, но пока с этим разберись.
|
а ну ка раскажи, чет недогоняю...