DO
take input keyboard
Clearscreen
print help output at 1,1
FOR all balls
IF ball has Y >0
it draws ball
it calculates new position
IF newPosition is out of screen
it decrease counter of active balls
IF userPress SpaceBar
IF counter of active balls is not max
It increases counter of active balls
it setups new ball position
UNTIL userPress EscapeKey
CONST YVel = 5, Hscreen = 400, Wscreen = 600, Rball = 10, MaxBall = 10
CONST Blu = _RGB32(0, 0, 255)
DIM Yball(1 TO MaxBall) AS INTEGER, A AS LONG, W AS INTEGER, CountBall AS INTEGER
A = _NEWIMAGE(Wscreen, Hscreen, 32)
IF A < -2 THEN SCREEN A ELSE PRINT "Error in Screen setup"
DO
CLS
LOCATE 1, 1: PRINT " press Space to shoot, Esc to quit Countball="; CountBall
PRINT " to test the issue press space while balls arrive to the top of screen"
CountBall = 0
FOR W = 1 TO MaxBall
IF Yball(W) > 1 THEN
CIRCLE (200, Yball(W)), Rball, Blu
PAINT STEP(0, 0), Blu, Blu
Yball(W) = Yball(W) - YVel
END IF
IF Yball(W) > 0 THEN CountBall = CountBall + 1
NEXT
k& = _KEYDOWN(32)
WHILE k&
IF CountBall < MaxBall THEN
CountBall = CountBall + 1
Yball(CountBall) = (Hscreen - (2 * Rball))
END IF
k& = 0
WEND
_LIMIT 50
LOOP UNTIL _KEYDOWN(27)
END
If the key is down, there is no no command that will force it up. It's down because the user is pressing it down.