Ok, there's a lot of problems with this code, A_Human. It won't even compile in its present state on account of several logic errors. Let's take a look:
First of all, you've got a LOOP command without a corresponding DO command. When the program hits the LOOP it doesn't know where to loop back to. You need to add the command DO at the very top of the program, it should be the first line.
Next, as Kamac said, your ENDIF's are in the wrong locations. Each ENDIF should come in before the next IF, like so:
If FirePosY(N) =< 0
FireFlag(N) = 0
Dec FireCount
Endif
If FirePosY(N) >= 1600
FireFlag(N) = 0
Dec FireCount
EndIf
Now, assuming MaxFire has been assigned elsewhere to a nonzero value, and you correct the positioning of your ENDIF's, you only have two lines of cleanup code to add to this subroutine to wrap it up. At two points in this sub, you are resetting the fireflag and decreasing the firecount (ie, deleting the fireball). At each of these two points you will also want to delete the corresponding sprite with DELETE SPRITE 19+N, because otherwise the next time the fireball you've just cleared gets created, you'll be trying make a second sprite where one already exists and the program will crash.
You might consider removing the SYNC command from this subroutine as well, since you're already calling SYNC before you call your LOOP at the top of the program.
Now, let's take a look at the addfireball subroutine. Assuming the character firing the projectile is sprite number 1, you seem to be setting the sprite up correctly here. My one gripe would be that you are using the EXIT command, which I forbid outright. You are never closing the IF with an ENDIF when you use EXIT, which creates stack problems down the track (explaining the "stack" might be outside the scope of your learning at this stage, but you can look that up if you like). Instead, a quick way of aborting the FOR... NEXT loop is to set N to MaxFire instead of using EXIT. When the NEXT N command is run, it doesn't realise that you've made it skip a bunch of iterations, it'll just see that it's now reached the limit of MaxFire, so it'll stop looping. In this way, the ENDIF command is reached every time, without ever creating more than one fireball per keypress.
Now, there's one other problem with this code, and that has to do with speed. When you use KEYSTATE at the top of this code, within a DO... LOOP iteration, the program is going to execute that KEYSTATE command hundreds of times per second. When you tap the I key, you'll probably create all 20 fireballs in a fraction of a second.
I suggest you use the TIMER command to restrict the number of fireballs per second. Replace the first few lines of code with this:
`*****Hit Key "T" *****
DO
IF KEYSTATE(20) = 1 AND TIMER() - lastfireball > 100 THEN GOSUB AddFireBall
IF FireCount > 0 THEN GOSUB MoveFireBall
SYNC
LOOP
Now, add a new line of code to addfireball:
lastfireball = TIMER()
Put that line right after you increment FireCount. Now you can only fire one fireball every 1/10th of a second, which means you can tap the I key to lob a single fireball, or you can hold down the I key to launch a volley of fireballs at a rate of ten per second. If you want to change this rate, adjust the number 100 in the TIMER() - lastfireball check. The lower the number, the faster the fireballs but the more risk of firing more than one per tap.
See how you go with these adjustments. If you have more questions, let me know.