Тема: Змейка
Показать сообщение отдельно
Старый 07.10.2007, 12:03   #20
Fant
Бывалый
 
Регистрация: 05.09.2005
Сообщений: 623
Написано 4 полезных сообщений
(для 5 пользователей)
Re: Змейка

Вообщем мне тут немного помгли с кодом зейки, но не совсем все красиво! Если кто-то найдет ошибку или сможет как-то исправить, то помогите пожалуйста!
;Eieoeaeecaoey.
Graphics3D 640,480,32,2
Camera = CreateCamera ()
Light = CreateLight ()
SetBuffer BackBuffer()
 
PositionEntity Camera , 0 , 15 ,0
RotateEntity Camera , 60 , 0 , 0
 
Global x[10], y[10], Rotat[10], a , cube[10], i
Global Time
;Nicaaai eoaeee e aaeaai eo ia?aeuiia iiei?aiea.
For i = 0 To 9
Cube[i] = CreateCube ()
PositionEntity Cube[i] , 0 , 0 , 3-(i*3)
EntityColor Cube[i], Rand(255),Rand(255),Rand(255) 
Next
 
a=1
Rotat[0] = 1
;---------------
While Not KeyDown (1)
Cls
;Iaiyai aae?aiea aieiau
If KeyDown (200) Then a = 1
If KeyDown (208) Then a= 2
 
If KeyDown (203) Then a = 3
 
If KeyDown (205) Then a = 4
 
If Time < MilliSecs () Then Time = MilliSecs () + 100 : a ()
UpdateWorld ()
RenderWorld ()
b ()
Flip ()
Wend
;a aio e naiia aeaaiia
Function A ()
For i = 0 To 9
x[i] = EntityX (cube[i])
y[i] = EntityZ (cube[i])
Next
For i = 1 To 9
If EntityX (cube[i]) < x[i-1] Then rotat[i] = 4
If EntityX (cube[i]) > x[i-1] Then rotat[i] = 3
If EntityZ (cube[i]) < y[i-1] Then rotat[i] = 1
If EntityZ (cube[i]) > y[i-1] Then rotat[i] = 2
Next
 
Rotat[0] = a
End Function
Function B ()
For i = 0 To 9
Select Rotat[i]
Case 1: MoveEntity cube[i], 0 , 0 , +0.1
Case 2: MoveEntity cube[i], 0 , 0 , -0.1 :
Case 3: MoveEntity cube[i], -0.1 , 0 , 0 :
Case 4: MoveEntity cube[i], +0.1 , 0 , 0 :
End Select
Next
End Function
(Offline)
 
Ответить с цитированием