Here is a basic code I just wrote:
Rem ***** Main Source File *****
sync on
sync rate 60
hide mouse
`make player
make object box 1,10,10,10
color object 1,RGB(0,128,0)
`\
`make ground
make matrix 1,1000,1000,10,10
position matrix 1,0,-10,0
`\
`Variables
type playerBul
bulletsExist as integer
shootCounter as integer
bulletSpeed as integer
endtype
playerBullets as playerBul
playerBullets.bulletsExist = 1
playerBullets.shootCounter = 20
playerBullets.bulletSpeed = 1
`\
do
`Bullet counter
dec playerBullets.shootCounter,1
if playerBullets.shootCounter < 1
playerBullets.shootCounter = 0
endif
`\
`player controls
if keystate(200) = 1
move object 1,1
endif
if keystate(208) = 1
move object 1,-1
endif
if keystate(203) = 1
yrotate object 1,object angle y(1)-2
endif
if keystate(205) = 1
yrotate object 1,object angle y(1)+2
endif
if keystate(57) = 1 and playerBullets.shootCounter < 1
inc playerBullets.bulletsExist,1
make object sphere playerBullets.bulletsExist,5,5,5
color object playerBullets.bulletsExist,RGB(255,0,0)
position object playerBullets.bulletsExist,object position x(1),object position y(1)+5,object position z(1)
rotate object playerBullets.bulletsExist,object angle x(1),object angle y(1),object angle z(1)
playerBullets.shootCounter = 20
endif
`\
`Check to see if bullets should be moved
for moveBullets = 2 to playerBullets.bulletsExist
if object exist(moveBullets) = 1
move object moveBullets,2
endif
next moveBullets
`\
`Camera settings
rotate camera 0,0,0,0
position camera 0,object position x(1),object position y(1)+20,object position z(1)
rotate camera 0,object angle x(1),object angle y(1),object angle z(1)
move camera 0,-50
`\
sync
loop
It's a third person with shooting, you should get a basic idea of how you could make a shooting system with that... Walk around with the arrowkeys and shoot by pressing the spacebar....
Just note a few things in this code... The bullets you shoot out dosn't get deleted any time... In your game, be sure to somehow delete bullets again!
This isn't the best way of doing things... You could eventually use something like raycasting for shooting systems... For something like fps shooting system, you would problaly be best off using raycasting.
Hope it helps a bit
-The Nerd