Тема: сос
Показать сообщение отдельно
Старый 16.10.2005, 00:18   #7
Guest
 
Сообщений: n/a
у меня есть код! и ресурсы,короче у меня холмистая местность,могу ходить тока по низинам(ровной поверхности) а холмы на сквозь прхожу.
;инициализация графики
Graphics3D 800,600,32
SetBuffer BackBuffer()

Global user
Global camera

Const G#=1

Const USERT=1;for user
Const TERRT=2;for terrain
Const SHOTT=3;for shot
Const BOTT=4;for bot

Global pricel=LoadImage("C:/media/pricel2.bmp")
Global shot_sprite=LoadSprite("C:/media/sprite.bmp")

Type shot
Field entity
Field dist#
End Type

Type bot
Field entity
End Type

;создание игрока
Function create_user(x#=0,y#=10,z#=0)

MidHandle pricel
MaskImage pricel,255,255,255

user=CreateSphere()
k#=3
ScaleEntity user,k#,k#,k#
EntityRadius user,k#
camera=CreateCamera(user)
CameraRange camera,0.1,100
PositionEntity user,x#,y#,z#
EntityType user,USERT

End Function

;обновление игрока
Function update_user()

V#=0.5
u#=70;предельный угол
TurnEntity camera,MouseYSpeed(),0,0
TurnEntity user,0,-MouseXSpeed(),0
If KeyDown(203)=1 Then MoveEntity user,-V#,0,0
If KeyDown(205)=1 Then MoveEntity user,V#,0,0
If KeyDown(200)=1 Then MoveEntity user,0,0,+V# 
If KeyDown(208)=1 Then MoveEntity user,0,0,-V#
MoveMouse GraphicsWidth()*0.5,GraphicsHeight()*0.5
If Abs(EntityPitch#(camera))>u# RotateEntity camera,u#*Sgn(EntityPitch#(camera)),0,0

If MouseHit(1) create_shot(EntityX(user),EntityY(user),EntityZ(user),EntityPitch(camera),EntityYaw(user),0)
;физика
TranslateEntity user,0,-G#,0
End Function

Function create_Shot(x#,y#,z#,pitch#,yaw#,roll#)
s.shot=New shot
s\entity=CopyEntity(shot_sprite)
EntityType s\entity,SHOTT
PositionEntity s\entity,x#,y#,z#,1
RotateEntity s\entity,pitch#,yaw#,roll#,1
Return True
End Function

Function update_shot()
vs#=1
max_dist#=1000
For a.shot=Each shot
 MoveEntity a\entity,0,0,vs#
 a\dist#=a\dist#+vs#
 bot_h=EntityCollided(a\entity,BOTT)
 If a\dist#>max_dist#
 FreeEntity a\entity
 Delete a
 ElseIf EntityCollided(a\entity,TERRT) <> 0
 FreeEntity a\entity
 Delete a
 ElseIf bot_h <> 0
 FreeEntity a\entity
 Delete a
 For q.bot=Each bot
  If q\entity=bot_h
  FreeEntity bot_h
  Delete q
  create_bot(EntityX(user)+Rnd(-100,100),2,EntityZ(user)+Rnd(-100,100))
  Exit
  EndIf
 Next
 EndIf
Next
End Function

Function create_bot(x#,y#,z#)
b.bot=New bot
b\entity=CreateSphere()
EntityType b\entity,BOTT
PositionEntity b\entity,x#,y#,z#
Return True
End Function

Function update_bot()
v#=0.3
For a.bot=Each bot
 PointEntity a\entity,user
 MoveEntity a\entity,0,0,v#
Next
End Function


;создание игрового мира
Function create_world()
light=CreateLight()
RotateEntity light,90,0,0
HideEntity shot_sprite
Pl= CreatePlane() 
tx=LoadTexture("C:/media/water.jpg");
EntityTexture Pl,tx;
FreeTexture tx
EntityPickMode pl,2
NameEntity pl,"Water"

create_user()

terrain= CreatePlane() 
Land=LoadTerrain("C:/media/land.png") 
EntityPickMode Land,2
NameEntity Land,"Land"
EntityType terrain,TERRT

tx=LoadTexture("C:/media/moss.jpg")

ScaleTexture tx,10.5,3.2
EntityTexture terrain,tx 
EntityTexture land,tx 
FreeTexture tx

ScaleEntity terrain,5,1,5
ScaleEntity Land,5,80,5
MoveEntity Land,-256*5,-20,-256*5
MoveEntity terrain,0,-20.001,0
create_user()

c_bot=Input("input Amount")
For i=1 To c_bot
 create_bot(Rnd(-100,100),2,Rnd(-100,100))
Next

Collisions USERT,TERRT,2,3
Collisions SHOTT,SH,2,1

Collisions BOTT,TERRT,2,3
Collisions BOTT,USERT,2,3
Collisions BOTT,BOTT,2,3

Collisions USERT,BOTT,2,3

Collisions SHOTT,BOTT,2,1
End Function
;функции закончились 
;--------------------------------
create_world()

;MAIN LOOP
While Not KeyHit(1)=1
update_user()
update_shot()
update_bot()
UpdateWorld()
RenderWorld()
DrawImage pricel,MouseX(),MouseY()
Flip
Wend
;----------------------------
 
Ответить с цитированием