столкновения
Наверно тема не 1 уже поднималась :) ,но всеже помогите разобраться с колизией.
Задал константы... присвоил тип..., а колизия работать не хочет.
Мб че не там написал? Сам уже 2 день воткнуть не могу что не так :(
вот код:
Цитата:
Graphics3D 800,600,32,0
SetBuffer BackBuffer()
Const SHOOT=1
Const PLANEc=2
Const PLAYERc=3
Const G#=1
Global player=CreateSphere()
Global camera=CreateCamera(player)
Global pm=LoadMesh("PM.b3d",camera)
Global plane=CreatePlane()
Global pricel=LoadImage("pricel.png")
Global jump_speed
EntityType player,PLAYERc
EntityType plane,PLANEc
Global shoot_sprite=LoadSprite("texture/FPS-Shot.png")
ScaleSprite shoot_sprite,0.2,0.2
PositionEntity shoot_sprite,6.4,0,0
EntityType shoot_sprite,SHOOT
HideEntity shoot_sprite
Type Shoot
Field entity
Field time_out
End Type
Type Jump
Field yJump
Field speedJump
End Type
CreatePlayer
CreateWorld
Collisions PLAYERc,PLANEc,2,3
While Not KeyHit(1)
MouseControl()
V#=0.2
If KeyDown(30) MoveEntity player,-V#,0,0
If KeyDown(32) MoveEntity player,V#,0,0
If KeyDown(17) MoveEntity player,0,0,V#
If KeyDown(31) MoveEntity player,0,0,-V#
If MouseHit(1)
CreateShoot(pm)
EndIf
If MouseDown(2)
createshoot(pm)
EndIf
For s.shoot=Each shoot
UpdateShoot( s )
Next
;------JUMP--------
gravity#=0.01
jumpvel#=0.2
If jumping=0
If KeyHit(57) Then yvel#=jumpvel# jumping=1
TranslateEntity player,0,-G#,0
EndIf
If jumping=1
yvel#=yvel#-gravity#
by#=by#+yvel#
EndIf
If by#<1 Then by#=1 yvel#=0 jumping=0
MoveEntity player,0,yvel#,0
;-------END JUMP-------
RenderWorld
DrawImage pricel,MouseX(),MouseY()
Flip
Wend
End
;---------------------------
Function CreateWorld()
light=CreateLight()
RotateEntity light,90,0,0
texplane=LoadTexture("texture/ground.jpg")
EntityTexture plane,texplane
EntityType plane,PLANEc
End Function
;---------------------------
Function CreatePlayer()
MidHandle pricel
MaskImage pricel,0,0,0
ScaleEntity player,0.3,0.3,0.3
PositionEntity player,0,50,0
EntityType player,PLAYERc
PositionEntity camera,0,0,0
CameraRange camera,0.1,10000
ScaleEntity pm,0.009,0.009,0.009
PositionEntity pm,0.5,-0.2,1
RotateEntity pm,0,90,0
End Function
;----------------------------
Function CreateShoot.shoot(pm)
s.shoot=New shoot
s\time_out=150
s\entity=CopyEntity(shoot_sprite,pm)
EntityParent s\entity,0
Return s
End Function
;----------------------------
Function UpdateShoot(s.shoot)
s\time_out=s\time_out-1
If (s\time_out=0)
FreeEntity s\entity
Delete s
Return
EndIf
MoveEntity s\entity,0.2,0,0
End Function
;----------------------------
Function MouseControl()
u#=70
TurnEntity camera,MouseYSpeed(),0,0
TurnEntity player,0,-MouseXSpeed(),0
MoveMouse GraphicsWidth()*0.5,GraphicsHeight()*0.5
If Abs(EntityPitch#(camera))>u# RotateEntity camera,u#*Sgn(EntityPitch#(camera)),0,0
End Function
;---------------------------
Function Jump()
gravity#=.01
jumpvel#=.3
If jumping=0
If KeyHit(57) Then yvel#=jumpvel# jumping=1
EndIf
If jumping=1
yvel#=yvel#-gravity#
by#=by#+yvel#
EndIf
If by#<1 Then by#=1 yvel#=0 jumping=0
MoveEntity player,0,yvel#,0
End Function
;---------------------------
|
|