Hi all ,I'm making a game and everythings fine (apart from the code being a little messy). My prolem is that when I press the spacebar to shoot the program goes to a sub-routine and stops the rest of the program until the sub-routine has finished.Heres the code so far. Any help will be really appreciated.Thanks.
` variables and colours
ink 0,rgb(0,128,255)
cls
plx=320
eny=50
enx=(rnd(640))
buly=390
sync on
`draw players plane
load bitmap "spitfire.bmp",1
get image 1,0,415,46,446,1
sprite 1,plx,400,1
`draw plane 1 from center
spritewidth=(sprite width(1)/2)
spriteheight=(sprite height(1)/2)
offset sprite 1,spritewidth,spriteheight
`draw enemy plane
load bitmap "en spit.bmp",2
get image 2,12,404,58,435,2
sprite 2,enx,eny,2
`draw plane 2 from center
spritewidth=(sprite width(2)/2)
spriteheight=(sprite height(2)/2)
offset sprite 2,spritewidth,spriteheight
`draw player bullet
load bitmap "spitbul.bmp",3
get image 3,9,427,32,432,3
sprite 3,plx,buly,3
hide sprite 3
`draw player bullet from center
spritewidth=(sprite width(3)/2)
spriteheight=(sprite height(3)/2)
offset sprite 3,spritewidth,spriteheight
`start main loop
do
sync
`player movement
if spacekey()=1 then gosub bulpos
if leftkey()=1 then plx=plx-5
if rightkey()=1 then plx=plx+5
if plx<=0 then plx=0
if plx>=640 then plx=640
sprite 1,plx,400,1
sprite 3,plx,buly,3
`enemy movement
eny=eny+4
if eny>=500
eny=0
enx=(rnd(640))
endif
sprite 2,enx,eny,2
loop
bulpos:
repeat
sprite 3,plx,buly,3
if spacekey()=1 then show sprite 3
sync
buly=buly-10
until buly=0
if buly=0 then buly=390
if spacekey()=0
hide sprite 3
endif
return
"fireball"