I'm doing a PONG game for my software design class, and whatever I do, I cannot get my bat to work, it's driving me nuts.
Can someone please have a look at it?
Code: Select all
CLS
REM Demo Only
REM Initialisation
mbatx = 1
mbaty = 12
pbatx1 = 79
pbaty1 = 12
pbatx2 = 79
pbaty2 = 13
pbatx3 = 79
pbaty3 = 14
xpos = 2
ypos = 13
xposscore = 2
xdir = 1
ydir = 1
xincrement = 1
yincrement = .25
REM Introductory Screen
PRINT
PRINT TAB(6); "This is PONG the first ever computer game."
PRINT
PRINT TAB(6); "Machine is on the left."
PRINT TAB(20); "You are on the right."
PRINT
PRINT TAB(6); "Move the paddle with the up and down arrows."
PRINT
PRINT TAB(6); "Best out of 3."
PRINT TAB(6); "For every round you win, the speed increases."
PRINT
PRINT
INPUT "Enter the speed you prefer [1/9] slowest/fastest"; speed
CLS
DO WHILE playscore = 0 AND machscore = 0
REM User Score Interface
PRINT "Player", , , , "Com"
PRINT playscore, , , , machscore
REM Draw Machine Bat
DO WHILE mbaty = 1 OR mbaty <= 22
mbaty = ypos - 1
LOCATE mbaty, mbatx
PRINT "|"
PRINT "|"
PRINT "|"
REM Draw Player Bat
LOCATE pbaty1, pbatx1
PRINT "|"
LOCATE pbaty2, pbatx2
PRINT "|"
LOCATE pbaty3, pbatx3
PRINT "|"
IF pbaty < 22 AND INKEY$ = CHR$(80) THEN pbaty = pbaty - 1
IF pbaty > 2 AND INKEY$ = CHR$(72) THEN pbaty = pbaty + 1
REM Motion Part
xpos = xpos + (xdir * xincrement)
ypos = ypos + (ydir * yincrement)
LOCATE ypos, xpos
PRINT CHR$(15)
REM Delay loop
FOR d = 1 TO (35000 - speed * 3000)
NEXT d
REM Move Player Bat
IF INKEY$ = CHR$(24) THEN
pbaty1 = pbaty1 - 1
pbaty2 = pbaty2 - 1
pbaty3 = pbaty3 - 1
END IF
REM Move Machine Bat
REM Bounce off Walls
IF xpos = 79 THEN
IF ABS(ypos - pbaty - 1) < 1.5 THEN xdir = xdir * -1
END IF
IF xpos = 2 THEN
IF ABS(ypos - mbaty - 1) < 1.5 THEN xdir = xdir * -1
END IF
IF xpos < 2 THEN xdir = xdir * -1
IF ypos > 22 THEN ydir = ydir * -1
IF ypos < 2 THEN ydir = ydir * -1
REM Refresh the screen
IF xpos = 80 THEN xdir = xdir * -1
CLS
REM Scoring System
IF xposscore > 79 THEN playscore = playscore + 1
IF xposscore < 2 THEN machscore = machscore + 1
LOOP
LOOP
END
~Kyle Out