Here is my full game code. The shooting part is in the main loop near the middle.. With this code I have here, if I click or click and hold my mouse button, only one or two bullets come out, then it waits for bullet life to equal 0 and then it shoots one or two more even though I'm holding the mouse down. Now, my gun is a machine gun and I need the bullets to come out not one by one, but very rapidly like a machine gun. Thanks for all your help, if you help me!
sync on
hide mouse
fog on
rem the music
load music "media\menu.wav",1
loop music 1
load sound "media\p228-2.wav",1
load sound "media\clipin.wav",2
rem the opening
cls
Input "What is your name ", name$
print "Hello " ; name$
print "I'll see you on the battlefield!"
wait 1100
set cursor 250,185
print "Loading textures"
wait 750
set cursor 250,200
print "Loading matrix"
wait 100
set cursor 250,215
print "Loading weapons"
wait 850
set cursor 250,230
print "Loading sounds"
wait 900
set cursor 250,245
print "Loading music"
wait 775
set cursor 250,260
print "Done Loading!!"
wait 650
sync
rem the backdrop
backdrop on
color backdrop 12
rem the gun
load object "media\assult.x",1
rem Get it facing the right way
yrotate object 1,90
fix object pivot 1
rem Make it a better size
scale object 1,410,410,410
rem THIS IS WHERE THE GUN IS PLACED. CHANGE THESE TO MOVE THE GUN.
position object 1,25,-32.5,50
rem THIS COMMAND LOCKS AN OBJECT TO THE SCREEN. LOOK IT UP IN THE HELP
lock object on 1
sync
Rem Make bullet
Make Object Sphere 3,1
position object 3,25,31,50
Hide Object 3
rem the matrix
load image "media\grass01.bmp",1
rem Make a simple scene for the camera to look at
make matrix 1,10000.0,10000.0,30,30
load bitmap "media\grass01.bmp",1
get image 1,0,0,256,256
delete bitmap 1
prepare matrix texture 1,1,2,2
randomize matrix 1,295.0
rem Draw aim
cls
Ink RGB(255,0,0),0
Circle Screen Width()/2, Screen Height()/2, 10
Dot Screen Width()/2, Screen Height()/2
sync
rem Position camera
position camera 5000,200,5000
rem Activate manual sync
sync on
rem Begin loop
do
rem the collison for 3d objects
SET GLOBAL COLLISION ON
rem the bullet shooting
if Mouseclick()=1 and BulletLife=0
Position object 3,X#+15,Y#+43.5,Z#
Set object to camera orientation 3
BulletLife=20
Show object 3
Endif
If BulletLife > 0
Dec BulletLife
Move object 3,20
If BulletLife = 0 then Hide object 3
Endif
ammo=10
If mouseclick()=1 and sound playing(1)=0 and ammo>0
ammo=ammo-1
play sound 1
endif
if mouseclick()=2 and sound playing(2)=0
ammo=10
play sound 2
endif
sync
rem Control camera with arrow keys
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)
Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,10)
ZTest# = Newzvalue(Z#,CameraAngleY#,10)
If XTest#>0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#