Qbasicnews.com

Full Version: need help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im trying to make this 2 player pong sort of game and i've run into a problem.
If player 1 wants to move up and so holds "q"(up), while player 2 wants to move down so at the same time holds "l"(down), then the the first player stops moving.
Like how if you hold down a and then press and hold d then it look like this.
aaaaaaaaaaaaaaaaddddddddddddddddd
I can make it so if player 1 starts moving down and player 2 presses something then player 1 keeps moving.
But i really want the bat to stop moving when you let go of the button.
Can anyone help?
My current program is this:


RANDOMIZE TIMER
13 j = -2 + INT(RND * 5)
IF j = 0 THEN GOTO 13
14 o = -2 + INT(RND * 5)
IF o = 0 THEN GOTO 14
v = 0
n = 0
1 RANDOMIZE TIMER
SCREEN 7, 0, 1, 0
s% = 1
h% = 1
x = 1
y = 100
a = 320
b = 100
l = 90 + RND * 20
m = 150 + RND * 20
DO
IF m < x THEN
v = v + 1
GOTO 1
END IF
IF m > a THEN
n = n + 1
GOTO 1
END IF
CLS
PRINT " p1 score="; n; " p2 score="; v
LINE (x, y)-(x + 5, y + 20), 15, BF
LINE (a, b)-(a - 5, b + 20), 15, BF
CIRCLE (m, l), 4, 1
PAINT (m, l), 1
m = m + j
l = l + o
IF l < 2 THEN o = o + 1
IF l > 195 THEN o = o - 1
IF m < x + 5 AND l > y - 5 AND l < y + 25 THEN
m = x + 5
j = j + 4
END IF
IF m > a - 5 AND l > b - 5 AND l < b + 25 THEN
m = a - 5
j = j - 4
IF j > 2 THEN j = 2
IF j < -2 THEN j = -2
END IF
p1$ = INKEY$

SELECT CASE p1$
CASE "q"
a% = 1
CASE "a"
a% = 2
CASE "p"
b% = 1
CASE "l"
b% = 2
CASE "x"
END
END SELECT

SELECT CASE a%
CASE 2
IF y < 180 THEN y = y + s%
CASE 1
IF y > 0 THEN y = y - s%
END SELECT

SELECT CASE b%
CASE 2
IF b < 180 THEN b = b + h%
CASE 1
IF b > 0 THEN b = b - h%
END SELECT
PCOPY 1, 0
LOOP


Yes, i know it has a lot of useless stuff in it, ive just started with qbasic and im also lazy so if anything is redundant il probably leave it in rather than take it out.
Triple post :x