Ok, I made the bullet longer, and now you cant shoot it through the corners of the boxes, which is really sweet. The only problem is that I'd like the bullet to end up hitting the center of the screen, just like a real FPS, however I dont really know how to get that to happen, while still having the gun off-centered. I was planning on making crosshairs just with lines on the screen, but it'd look funny if the bullet was shooting 5 feet to the right, or the crosshairs were off centered ; ( Is there any easy way to adjsut the bullet trajectory to always hit in the center, no matter how far it goes? (like, faking that it's shooting from off-center or something?)
Here's the longer bullet if you wanna mess with it:
rem Settings
Sync On
Sync Rate 60
autocam off
Hide mouse
Backdrop on
Color Backdrop RGB(128,128,128)
rem load files
rem load sound "gunshot.wav",1
rem create targets
For x = 100 to 104
Make object cube x,75
Position object x,Rnd(1000),Rnd(10),Rnd(1000)
Set object collision to boxes x
Next x
rem Create Ground
Make Matrix 1,1000,1000,5,5
Load image "ground.bmp",1
Prepare matrix texture 1,1,2,2
rem Make Gun
Make object cylinder 1,2
XRotate Object 1,90
Fix object pivot 1
Scale object 1,100,100,500
position object 1,5,-7,15
Lock object on 1
Set object collision to boxes 1
rem Make Bullets
Make object cylinder 2,2
XRotate Object 2,90
Fix object pivot 2
Scale object 2,50,50,1100
Set object collision to boxes 2
Hide Object 2
rem Make player col
make object sphere 3,25
set object collision to boxes 3
Rem Main loop
Do
rem mouse movement
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
rem mouse movement
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)
rem foward walking
If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,10)
ZTest# = Newzvalue(Z#,CameraAngleY#,10)
If XTest#>0 and XTest#<1000 and ZTest#>0 and ZTest#<1000
X#=XTest#
Z#=ZTest#
Position object 3,Xtest#,0,ZTest#
Endif
Endif
rem backward walking
If Downkey()=1
XTest# = Newxvalue(X#,Wrapvalue(CameraAngleY#-180),10)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#-180),10)
If XTest#>0 and XTest#<1000 and ZTest#>0 and ZTest#<1000
X#=XTest#
Z#=ZTest#
Position object 3,XTest#,0,ZTest#
Endif
Endif
rem strafe left
If Leftkey()=1
XTest# = Newxvalue(X#,Wrapvalue(CameraAngleY#-90),5)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#-90),5)
If XTest#>0 and XTest#<1000 and ZTest#>0 and ZTest#<1000
X#=XTest#
Z#=ZTest#
Position object 3,XTest#,0,ZTest#
Endif
Endif
rem strafe right
If Rightkey()=1
XTest# = Newxvalue(X#,Wrapvalue(CameraAngleY#+90),5)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#+90),5)
If XTest#>0 and XTest#<1000 and ZTest#>0 and ZTest#<1000
X#=XTest#
Z#=ZTest#
Position object 3,XTest#,0,ZTest#
Endif
Endif
rem mouse movement
Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)
rem camera position
Y# = Get ground height(1,X#,Z#)
Position Camera X#,Y#+50,Z#
rem bullet collision
If Object collision(2,0)>0 then bulletlife=0
bX#=Object position X(2)
bY#=Object position Y(2)
bZ#=Object position Z(2)
if bY# < 0 then BulletLife=0
rem shooting
if Mouseclick()=1 and BulletLife=0
Position object 2, newxvalue(X#, wrapvalue(CameraAngleY# + 68.1986), 5.3851), Y# + 43, newzvalue(Z#, wrapvalue(CameraAngleY# + 68.1986), 5.3851)
Set object to camera orientation 2
BulletLife =25
show object 2
rem play sound 1
inc totalshots
Endif
rem display total shots
set cursor 0,0
print "Total Shots: ", totalshots
rem bullet life
If BulletLife > 0
Dec BulletLife
Move object 2,30
if BulletLife = 0 then Hide object 2
Endif
Rem Refresh Screen
Sync
Loop
I'm getting around to fixing the whole bullet shooting funny at different angles, and you being able to do backflips forever with the mouse : P