Try this...it won't fire the next bullet until space is let up...
rem print instructions
PRINT "Use arrow keys to move target up, down, left and right."
Print "Shift for away, ctrl for closer."
Print "Space to shoot"
Print "The amount of cicles in top left corner indicates ammo remaining."
Print "Ammo shoudl reload when all out"
Print "Press enter to manually reload"
Print "press any key to continue."
suspend for key
rem set sync ect
sync on : sync rate 60
hide mouse
rem make bullets
for t=1 to 3
make object cube t, 0.07
hide object t
next t
bulletlife1=100
bulletfired1=0
bulletlife2=100
bulletfired2=0
bulletlife3=100
bulletfired3=0
rem make target
make object cube 4, 1
rem main loop
do
rem get target positions
tarx=object position x(4)
tary=object position y(4)
tarz=object position z(4)
rem move target
if upkey()=1 then tary=tary+1
if downkey()=1 then tary=tary-1
if leftkey()=1 then tarx=tarx-1
if rightkey()=1 then tarx=tarx+1
if shiftkey()=1 then tarz=tarz+1
if controlkey()=1 then tarz=tarz-1
rem shoot
if spacekey()=1 and spacedown=0
if bulletfired1=0
point object 1,tarx,tary,tarz
bulletfired1=1
show object 1
goto endshoot
endif
if bulletfired2=0 and bulletfired1=1 and firedelay1=40
point object 2,tarx,tary,tarz
bulletfired2=1
show object 2
goto endshoot
endif
if bulletfired3=0 and bulletfired2=1 and firedelay2=40
point object 3,tarx,tary,tarz
bulletfired3=1
show object 3
goto endshoot
endif
endshoot:
spacedown=1
else
spacedown=0
endif
if bulletfired1=1 and firedelay1<40 then firedelay1=firedelay1+1
if bulletfired2=1 and firedelay2<40 then firedelay2=firedelay2+1
rem decrease bullet life if it's fired
if bulletfired1=1 then bulletlife1=bulletlife1-1
if bulletfired2=1 then bulletlife2=bulletlife2-1
if bulletfired3=1 then bulletlife3=bulletlife3-1
rem kill bullet if bulletlife is less than one
if bulletlife1<1 then position object 1,0,0,0 : bulletlife1 = 100 : hide object 1 : firedelay1=0
if bulletlife2<1 then position object 2,0,0,0 : bulletlife2 = 100 : hide object 2 : firedelay2=0
if bulletlife3<1 then position object 3,0,0,0 : bulletlife3 = 100 : hide object 3 : firedelay2=0
rem kill bullet if it hits target
if object hit(1,4)=1
position object 1,0,0,0
bulletlife1 = 100
hide object 1
firedelay1=0
endif
if object hit(2,4)=1
position object 2,0,0,0
bulletlife2 = 100
hide object 2
firedelay2=0
endif
if object hit(3,4)=1
position object 3,0,0,0
bulletlife3 = 100
hide object 3
firedelay3=0
endif
rem move bullet
if bulletfired1=1 then move object 1,0.5
if bulletfired2=1 then move object 2,0.5
if bulletfired3=1 then move object 3,0.5
rem ammo indicator
if bulletfired1=0 then circle 10, 10, 10
if bulletfired2=0 then circle 25, 10, 10
if bulletfired3=0 then circle 40, 10, 10
rem reload mag if empty
if bulletfired1=1 and bulletfired2=1 and bulletfired3=1 and object visible(1)=0 and object visible(2)=0 and object visible(3)=0
bulletfired1 = 0
bulletfired2 = 0
bulletfired3 = 0
endif
if returnkey()=1
bulletfired1 = 0
bulletfired2 = 0
bulletfired3 = 0
endif
rem position target
position object 4, tarx, tary, tarz
rem update screen
sync
rem end main loop
loop
Or this, which is a timer based delay system...so you can only shoot once a second...
rem print instructions
PRINT "Use arrow keys to move target up, down, left and right."
Print "Shift for away, ctrl for closer."
Print "Space to shoot"
Print "The amount of cicles in top left corner indicates ammo remaining."
Print "Ammo shoudl reload when all out"
Print "Press enter to manually reload"
Print "press any key to continue."
suspend for key
rem set sync ect
sync on : sync rate 60
hide mouse
rem make bullets
for t=1 to 3
make object cube t, 0.07
hide object t
next t
bulletlife1=100
bulletfired1=0
bulletlife2=100
bulletfired2=0
bulletlife3=100
bulletfired3=0
rem make target
make object cube 4, 1
rem main loop
do
rem get target positions
tarx=object position x(4)
tary=object position y(4)
tarz=object position z(4)
rem move target
if upkey()=1 then tary=tary+1
if downkey()=1 then tary=tary-1
if leftkey()=1 then tarx=tarx-1
if rightkey()=1 then tarx=tarx+1
if shiftkey()=1 then tarz=tarz+1
if controlkey()=1 then tarz=tarz-1
rem shoot
if spacekey()=1 and timer()-shoottime>1000
if bulletfired1=0
point object 1,tarx,tary,tarz
bulletfired1=1
show object 1
goto endshoot
endif
if bulletfired2=0 and bulletfired1=1 and firedelay1=40
point object 2,tarx,tary,tarz
bulletfired2=1
show object 2
goto endshoot
endif
if bulletfired3=0 and bulletfired2=1 and firedelay2=40
point object 3,tarx,tary,tarz
bulletfired3=1
show object 3
goto endshoot
endif
endshoot:
shoottime=timer()
endif
if bulletfired1=1 and firedelay1<40 then firedelay1=firedelay1+1
if bulletfired2=1 and firedelay2<40 then firedelay2=firedelay2+1
rem decrease bullet life if it's fired
if bulletfired1=1 then bulletlife1=bulletlife1-1
if bulletfired2=1 then bulletlife2=bulletlife2-1
if bulletfired3=1 then bulletlife3=bulletlife3-1
rem kill bullet if bulletlife is less than one
if bulletlife1<1 then position object 1,0,0,0 : bulletlife1 = 100 : hide object 1 : firedelay1=0
if bulletlife2<1 then position object 2,0,0,0 : bulletlife2 = 100 : hide object 2 : firedelay2=0
if bulletlife3<1 then position object 3,0,0,0 : bulletlife3 = 100 : hide object 3 : firedelay2=0
rem kill bullet if it hits target
if object hit(1,4)=1
position object 1,0,0,0
bulletlife1 = 100
hide object 1
firedelay1=0
endif
if object hit(2,4)=1
position object 2,0,0,0
bulletlife2 = 100
hide object 2
firedelay2=0
endif
if object hit(3,4)=1
position object 3,0,0,0
bulletlife3 = 100
hide object 3
firedelay3=0
endif
rem move bullet
if bulletfired1=1 then move object 1,0.5
if bulletfired2=1 then move object 2,0.5
if bulletfired3=1 then move object 3,0.5
rem ammo indicator
if bulletfired1=0 then circle 10, 10, 10
if bulletfired2=0 then circle 25, 10, 10
if bulletfired3=0 then circle 40, 10, 10
rem reload mag if empty
if bulletfired1=1 and bulletfired2=1 and bulletfired3=1 and object visible(1)=0 and object visible(2)=0 and object visible(3)=0
bulletfired1 = 0
bulletfired2 = 0
bulletfired3 = 0
endif
if returnkey()=1
bulletfired1 = 0
bulletfired2 = 0
bulletfired3 = 0
endif
rem position target
position object 4, tarx, tary, tarz
rem update screen
sync
rem end main loop
loop
See anything you like?
Xander Moser - Bolt Software - Firewall