ok i just made another post because the other one had like 50 posts and i don't think anyone was reading it
. So:
i am making an fps, with an aiming system like counterstrike/halflife/battlefield 1942. for any of u unfamiliar with that, what happens is there is a crosshair which stays in the middle of the screen, and you move the mouse to aim. the gun is always pointing at the crosshair. Mostly THanks to zircher, i have gone this far in making the aiming system (no sarcasm intended). now, the problem is, if i move the mouse too much to the left or too much to the right, u cant see the gun anymore! its still pointing at the crosshair, i know that, but u cant see it cuz its rotating! how do i fix this? i will attach my code and hopefully someone can just take a look at it and offer a suggestion to fix this
. thanks in advance
oh yeah and zircher, just keep on posting on that other thread so we can keep our discussion going....
Rem Setup sync
Sync On
Sync Rate 30
autocam off
Rem make matrix
Make matrix 1,10000,10000,20,20
position matrix 1,-500,-200,-500
Rem texture matrix
Load image "sand.bmp",1
Prepare matrix texture 1,1,2,2
Rem Randomize the matrix
randomize matrix 1,250
Rem Place random texture on each matrix tile
For x = 0 to 19
For z = 0 to 19
t = rnd(3)+1
Set Matrix Tile 1,x,z,t
Next z
Next x
Rem Update the changes to the matrix
update matrix 1
Rem Make Cubes for reference
For x = 1 to 5
Make object cube x,100
Position object x,Rnd(2000),0,Rnd(2000)
Set object collision to boxes x
Next x
Rem make the m4a1 machine gun
load object "m4a1.3ds",10
scale object 10,2,2,2
position object 10,0,0,0
set object collision to boxes 10
rem the crosshair
make object plain 6, 1,1
color object 6, rgb(255,0,0)
angle_up# = 0
angle_side# = 0
Rem Main loop
Do
gX# = object position x(10)
gY# = object position y(10)
gZ# = object position z(10)
rem the technique that I'm going to use is that the camera is the player's head
rem and all movement and positions are based on that.
rem get the current position. We'll assume that world coordinates are in meters
rem so the camera is 175cm above the matrix
X# = camera position x()
Z# = camera position z()
Y# = Get Ground Height(1,X#,Z#)
rem this is basically 'mouse sensitivity'
angle_up#=wrapvalue(angle_up#+mousemovey()/10)
angle_side#=wrapvalue(angle_side#+mousemovex()/10)
rotate camera angle_up#, angle_side#, 0
Rem Control input for movement
If Upkey()=1
move camera 20
Endif
If downkey()=1
move camera -20
Endif
rem strafing
If leftkey()=1
position camera x#-20,y#,z#
Endif
If rightkey()=1
position camera x#+20,y#,z#
Endif
rem get new ground height
X# = camera position x()
Z# = camera position z()
Y# = Get Ground Height(1,X#,Z#)
rem reposition the camera
position camera X#,Y#,Z#
rem align and position gun
rotate object 10, camera angle x(),camera angle y(),camera angle z()
position object 10, X#,Y#,Z#
roll object right 10, 25
position object 10,gX#+.5,gy#,gZ#
roll object right 10, 25
rem align, position, and project cursor
rotate object 6, camera angle x(),camera angle y(),camera angle z()
position object 6, X#,Y#,Z#
move object 6, 30.0
Rem Refresh Screen
Sync
Loop