Бывалый
Регистрация: 09.09.2006
Сообщений: 656
Написано 54 полезных сообщений (для 110 пользователей)
|
Re: РПГ
попробуй так

Graphics3D 800,600,32,2
SetBuffer BackBuffer()
Type TPlayer
Field ent
Field piv
Field go
End Type
Global campiv=CreatePivot()
PositionEntity campiv,0,300,0
Global cam=CreateCamera(campiv)
TurnEntity cam,45,0,0
CameraRange cam ,1,10000
CreateLight(3,cam)
plane=CreatePlane()
EntityPickMode plane,2
planetex=CreatePlaneTexture()
ScaleTexture planetex,100,100
EntityTexture plane,planetex
Global Player.TPlayer=CreatePlayer()
Repeat
If MouseDown(1) Then
pick=CameraPick(cam,MouseX(),MouseY())
If pick=plane Then
PositionEntity Player\piv,PickedX(),20,PickedZ()
Player\go=True
EndIf
EndIf
UpdatePlayer(Player)
CameraUpdate()
RenderWorld
Flip
Until KeyDown(1)
Function CreatePlaneTexture()
Local tex=CreateTexture(128,12
Local buff=GraphicsBuffer()
SetBuffer TextureBuffer(tex)
Color 66,122,185
Rect 0,0,64,64
Rect 64,64,128,128
Color 183,234,247
Rect 64,0,128,64
Rect 0,64,64,128
SetBuffer buff
Return tex
End Function
Function CreatePlayer.TPlayer()
p.TPlayer=New TPlayer
p\ent=CreateCone()
RotateMesh p\ent,90,0,0
ScaleEntity p\ent,20,20,20
TranslateEntity p\ent,0,20,200
EntityColor p\ent,167,121,168
p\piv=CreatePivot()
Return p
End Function
Function CameraUpdate()
Local sp
If KeyDown(42) Then sp=3 Else sp=1
If KeyDown(17) Then MoveEntity campiv,0,0,sp
If KeyDown(31) Then MoveEntity campiv,0,0,-sp
If KeyDown(30) Then MoveEntity campiv,-sp,0,0
If KeyDown(32) Then MoveEntity campiv,sp,0,0
End Function
Function UpdatePlayer(p.TPlayer)
If Not p\go Then Return
PointToEntity(p\ent,p\piv,0.05)
MoveEntity p\ent,0,0,1
If EntityDistance(p\ent,p\piv)<6 Then p\go=False
End Function
Function PointToEntity( src, dest, softness# )
Local dx# = EntityX( src ) - EntityX( dest )
Local dy# = EntityY( src ) - EntityY( dest )
Local dz# = EntityZ( src ) - EntityZ( dest )
AlignToVector( src, -dx, -dy, -dz, 0, softness )
End Function
|
|