fps need some help

Blitz3D Forums/Blitz3D Beginners Area/fps need some help

melonhead(Posted 2012) [#1]
hi im having a little problem i manage to get the mouse to work with my code i spent a lot of time looking around the only problem i have is that it turns more then it should and was wondering if there a code that will make it more like a head turn that looks from shoulder to shoulder. here is what i have for my code

Global screen_width=800,screen_height=600
Global escape_key=1


;Camera Position and Angles
Global cam_x#,cam_z#,cam_pitch#,cam_yaw# ;Current
Global dest_cam_x#,dest_cam_z#,dest_cam_pitch#,dest_cam_yaw# ;Destination



Graphics3D screen_width,screen_height
SetBuffer BackBuffer()

camera=CreateCamera(cam1)

CameraViewport camera ,0,0,800,600
PositionEntity camera ,0,16,100


player1=CreateSprite()
PositionEntity player1,0,0,100
ScaleSprite player1,2.5,4
EntityParent camera,player1



dun_1=LoadMesh("dun_model/dun_1/dun-1.3ds")






While Not KeyHit(escape_key)

;control A,S,W,D -----------------

If KeyDown(17) Then
MoveEntity player1,0,0,.5
EndIf
If KeyDown(31) Then
MoveEntity player1,0,0,-.5
EndIf

If KeyDown(32) Then
TurnEntity player1,0,-.7,0
EndIf
If KeyDown(30) Then
TurnEntity player1,0,.7,0
EndIf





;control Mouse -------------------

;MOUSELOOK SUB-FUNCTION
If movement_allowed = 1
TurnEntity player, 0, -MouseXSpeed()/5.0, 0,0 ;rotate player Pivot according to mouse X movement
TurnEntity camera, MouseYSpeed()/5.0, 0, 0 ;rotate camera up/down according to mouse Y

MoveMouse GraphicsWidth()/2, GraphicsHeight()/2
If EntityPitch(camera) < -200 ;don't allow camera to look above 55 degrees
RotateEntity camera,-200, EntityYaw(camera), EntityRoll(camera)
EndIf

If EntityPitch(camera) > 30 ;don't allow camera to look below 30 degrees
RotateEntity camera, 30, EntityYaw(camera), EntityRoll(camera)
EndIf
End If
;---------


;Mouse x and y speeds
mxs=MouseXSpeed()
mxy=MouseYSpeed()


dest_cam_yaw#=dest_cam_yaw#-mxs
dest_cam_pitch#=dest_cam_pitch#+mys

cam_yaw=cam_yaw+((dest_cam_yaw-cam_yaw)/5)
cam_pitch=cam_pitch+((dest_cam_pitch-cam_pitch)/5)

RotateEntity camera,cam_pitch#,cam_yaw#,0



;---------------------------------


UpdateWorld

RenderWorld



Flip


Wend
End


i appreciate all the help


Happy Llama(Posted 2012) [#2]
If I understand, you want the camera to stop at about where each shoulder would be?


melonhead(Posted 2012) [#3]
after killing my self with it for a few days i found out how to do. i woke up from a dream about it and found out what i did wrong but if i have other problems. ill post them up.


jfk EO-11110(Posted 2012) [#4]
So it isn't only me who's coding in my dreams? Thought I'm kind of an alien or something :). I had some of my best ideas this way. Guess it's "lucent coding".
Anyway, good luck with your project.


Guy Fawkes(Posted 2012) [#5]
Lol!


Rob the Great(Posted 2012) [#6]
@jfk,
I woke up the other morning after having vivid dreams about code. It's a shame that I couldn't remember it later, but at the time, it all seemed to make sense.


jfk EO-11110(Posted 2012) [#7]
Been there. You should always have a notepad near your bed and write it down as long as you're still half sleeping.