Показать сообщение отдельно
Старый 09.12.2009, 19:01   #6
is.SarCasm
Бывалый
 
Аватар для is.SarCasm
 
Регистрация: 17.05.2009
Адрес: Днепропетровск
Сообщений: 672
Написано 180 полезных сообщений
(для 428 пользователей)
Ответ: Интересный глюк

ты сам этого захотел
Graphics3D 1280,1024,32,2
SetBuffer BackBuffer()

SeedRnd MilliSecs()

Global camPitch#, camYaw#, camDist#, mxs#, mys#, mzs#
cam = CreateCamera()
CameraRange cam,1,10000
eye = CreateSphere()
EntityAlpha eye,0.7
PositionEntity eye,256,0,256

Type cubozavr
Field HP
Field hungry#
Field entity
Field fatigue#
Field speed#
Field keks
Field a
End Type

Type cilozavr
Field HP
Field hungry#
Field entity
Field fatigue#
Field speed#
End Type

Type Bush
Field HP#
Field entity
End Type




font = LoadFont( "arial cyr",24 )
SetFont font











CreateBush(150,150)
CreateCilozavr(266,266)
CreateCubozavr(256,256)

Repeat


If KeyDown(17) MoveEntity eye,0,0,.2
If KeyDown(30) TurnEntity eye,0,2,0
If KeyDown(32) TurnEntity eye,0,-2,0


mxs = MouseXSpeed()
mys = MouseYSpeed()
mzs = MouseZSpeed()
RotateCamOver(cam, eye)


If KeyHit(2) Then
CreateCubozavr(Rnd(0,512),Rnd(0,512))
EndIf

If KeyHit(3) Then
CreateCilozavr(Rnd(0,512),Rnd(0,512))
EndIf

If KeyHit(4) Then
CreateBush(Rnd(0,512),Rnd(0,512))
EndIf


UpdateCilozavr()

z = z + 1



UpdateWorld
RenderWorld


Color 0,0,25



Text 5,20,"Цифра 1 - создать куб : Цифра 2 - создать цилиндр"
Text 5,40,"Отдалять камеру колесиком, вразать зажтием ПКМ"
Text 5,60,"Используйте W A D(клавиши)"+ z





DeleteBush()
UpdateCubozavr()
vFPS=MilliSecs()
If vFPS-vLastFPS>1000
vShowFPS=vCurFPS
vLastFPS=vFPS
vCurFPS=0
Else
vCurFPS=vCurFPS+1
End If
Text 5,30,"FPS: "+vShowFPS


Flip(1)

Until KeyHit(1)
End





Function RotateCamOver(cam, entity)
If MouseDown(2) Then
camPitch# = camPitch + (mys/4)
camYaw# = camYaw - (mxs/4)
EndIf
camDist# = camDist# + (mzs/1)
If camDist <= 1 Then camDist = 1
PositionEntity cam, EntityX(entity,1), EntityY(entity,1), EntityZ(entity,1), 1
RotateEntity cam, camPitch, camYaw, 0
MoveEntity cam, 0, 0, -camDist
End Function

Function CreateCubozavr(x,z)

Local p.cubozavr = New cubozavr
p\entity = CreateCube()
p\hp = 100
p\hungry# = 0
p\fatigue# = 0
p\speed# = 0.05
p\keks = 0
p\a = -1
PositionEntity p\entity,x,0,z
End Function

Function UpdateCubozavr()
For p.cubozavr = Each cubozavr
For x.cilozavr = Each cilozavr
p\hungry# = p\hungry# + 0.0025
If p\hungry<20 Then EntityColor p\entity,0,255,0
If p\hungry>20 And p\hungry<80 Then EntityColor p\entity,0,0,255
If p\hungry>80 Then EntityColor p\entity,255,0,0


MoveEntity p\entity,0,0,p\speed# :
p\fatigue# = p\fatigue# + 0.01:

If a = 0 Then
p\keks = p\keks + 1 :
EndIf

If p\keks>10 Then
p\keks = 0
EndIf

If p\keks = 10 Then
TurnEntity p\entity,0,Rnd(-5,5),0,0
EndIf





If p\hungry<0 Then
p\hungry = 0
EndIf

If p\fatigue# > 10 And p\fatigue# <20 Then
p\speed# =0.04
EndIf
If p\fatigue# > 20 And p\fatigue# <30 Then
p\speed# =0.035
EndIf
If p\fatigue# > 30 And p\fatigue# <40 Then
p\speed# =0.03
EndIf
If p\fatigue# > 40 And p\fatigue# <50 Then
p\speed# =0.025
EndIf
If p\fatigue# > 50 And p\fatigue# <60 Then
p\speed# =0.02
EndIf
If p\fatigue# > 80 And p\fatigue# <90 Then
p\speed# =0.01
EndIf

If p\fatigue#>99 Then
p\speed# =0.0 : p\fatigue# = p\fatigue#+0.015
EndIf

If p\fatigue#>299 Then
p\fatigue# = 0
EndIf

UpdateBushCubozavrAndCilozavr()

Next
Next
End Function






Function CreateCilozavr(xx,z)
Local x.cilozavr = New cilozavr
x\entity = CreateCylinder()
x\hp = 100
x\hungry# = 0
PositionEntity x\entity,xx,0,z

End Function

Function UpdateCilozavr()
For x.cilozavr = Each cilozavr
x\hungry# = x\hungry# + 0.007
If x\hungry<20 Then EntityColor x\entity,0,255,0
If x\hungry>20 And x\hungry<80 Then EntityColor x\entity,0,0,255
If x\hungry>80 Then EntityColor x\entity,255,0,0
Next
End Function

Function CreateBush(x,z)
Local h.Bush = New Bush
h\entity = CreateCone()
h\hp# = 100
PositionEntity h\entity,x,0,z
EntityColor h\entity,20,200,0
RotateEntity h\entity,180,0,0
ScaleEntity h\entity,2,2,2
End Function

Function DeleteBush()
For h.bush = Each bush
Text 500,800,""+h\HP#
If h\HP# < 1 Then
FreeEntity h\entity : Delete h
EndIf


Next
End Function

Function UpdateBushCubozavrAndCilozavr()
For p.cubozavr = Each cubozavr
For x.cilozavr = Each cilozavr
For h.Bush = Each bush

If EntityDistance(p\entity,x\entity)<30 Then
p\a = p\a + 1
EndIf

If EntityDistance(p\entity,x\entity)>30 Then
p\a = 0
EndIf

If p\a = 7 And EntityDistance(p\entity,x\entity)<30 Then
PointEntity(p\entity,x\entity) : TurnEntity p\entity, 0,-180,0
EndIf



If p\hungry > 20 And p\hungry<80 And EntityDistance(p\entity,x\entity)>30 Then
UpdateBushCubozavr3()
EndIf

If p\hungry < 20 And p\hungry>0 And EntityDistance(p\entity,x\entity)>30 Then
UpdateBushCubozavr2()
EndIf

If EntityDistance(p\entity,h\entity)<2 Then
p\hungry = p\hungry - ((0.021)*2.5) : h\HP# = h\HP# - 0.1
EndIf
Next
Next
Next
End Function

Function UpdateBushCubozavr2()
For p.cubozavr = Each cubozavr
For h.Bush = Each Bush
If EntityDistance(p\entity,h\entity)<20 Then
PointEntity p\entity,h\entity
EndIf

If EntityDistance(p\entity,h\entity)<2 Then
p\hungry = p\hungry - 0.00
EndIf
Next
Next
End Function

Function UpdateBushCubozavr3()
For p.cubozavr = Each cubozavr
For h.Bush = Each Bush
If EntityDistance(p\entity,h\entity)<35 Then
PointEntity p\entity,h\entity
EndIf
Next
Next
End Function

Function UpdateBushCubozavr4()
For p.cubozavr = Each cubozavr
For h.Bush = Each Bush
If EntityDistance(p\entity,h\entity)<60 Then
PointEntity p\entity,h\entity
EndIf
Next
Next
End Function
(Offline)
 
Ответить с цитированием