Yes, it can...

DECLARE SUB intro ()
DECLARE SUB game ()
DECLARE SUB delay (t AS SINGLE)
DECLARE FUNCTION timediff! (earlier AS SINGLE, later AS SINGLE)
DEFINT A-Z
WIDTH 80, 25
COLOR 2
intro
game

SUB delay (t AS SINGLE)
ST! = TIMER
DO: LOOP WHILE timediff(ST!, TIMER) < t
END SUB

SUB game

CONST NUMWORDS = 2
CONST NUMLEVELS = 4
DIM score(1 TO 2) AS INTEGER
DIM words(0 TO Numlevels - 1, 0 TO Numwords - 1) AS STRING

words(0, 0) = "syn"
words(0, 1) = "ack"
words(1, 0) = "ping"
words(1, 1) = "pong"
words(2, 0) = "thwack"
words(2, 1) = "bounce"
words(3, 0) = "rebound"
words(3, 1) = "deflect"

match = 11

player = 1
level = INT(RND * 2)
start = 0

DO
:::: LOCATE 5
:::: PRINT TAB(30); score(1); TAB(49); score(2)

:::: IF player = 1 THEN PRINT TAB(28); "Player 1"; TAB(60); ELSE PRINT TAB(47); "Player 2"

:::: LOCATE 10, 21
:::: PRINT STRING\$(40, "*");

:::: word = INT(RND * Numwords)
:::: entry\$ = ""
:::: DO: LOOP WHILE LEN(INKEY\$)
:::: FOR i = 0 TO 39
:::::::: LOCATE , 21 + i
:::::::: IF i < start THEN
:::::::::::: PRINT " ";
:::::::: ELSEIF i >= start + LEN(words(level, word)) THEN
:::::::::::: PRINT " ";
:::::::: ELSE
:::::::::::: PRINT MID\$(words(level, word), i - start + 1, 1);
:::::::: END IF
:::::::: ST! = TIMER
:::::::: DO
:::::::::::: K\$ = INKEY\$
:::::::::::: IF LEN(K\$) = 1 THEN
:::::::::::::::: IF entry\$ = "" THEN i1 = i
:::::::::::::::: entry\$ = entry\$ + K\$
:::::::::::::::: LOCATE 12, 21: PRINT entry\$
:::::::::::::::: LOCATE 10
:::::::::::::::: IF entry\$ <> LEFT\$(words(level, word), LEN(entry\$)) THEN i = 40: EXIT FOR
:::::::::::::::: IF entry\$ = words(level, word) THEN EXIT FOR
:::::::::::: END IF
:::::::: LOOP WHILE timediff(ST!, TIMER) < .02

:::: NEXT
:::: PRINT

:::: player = 3 - player
:::: IF i = 40 THEN
:::::::: score(player) = score(player) + 1
:::::::: level = INT(RND * 2)
:::::::: start = 0
:::: ELSE
:::::::: level = INT((i / 40) ^ 3 * Numlevels)
:::::::: start = 20 - ((i - i1) / 40) ^ (.5 + level / Numlevels) * 20
:::: END IF

:::: delay 1.5
:::: LOCATE 12, 20: PRINT SPACE\$(20)

LOOP WHILE score(1) < match AND score(2) < match

CLS
LOCATE 5, 37
IF score(1) = match THEN PRINT "P1 wins!" ELSE PRINT "P2 wins!"
END SUB

SUB intro

CLS
LOCATE 3, 33
PRINT "TEXT MODE PONG"
PRINT TAB(28); "Please press the any key."
SLEEP
PRINT: PRINT
PRINT TAB(4); "OBJECTIVE: Type the word that is revealed, before time runs out."
PRINT TAB(16); "If you press an incorrect key or run out of time,"
PRINT TAB(16); "you lose the point."
PRINT
PRINT TAB(5); "STRATEGY: Shortening the time between your first keystroke and last"
PRINT TAB(16); "keystroke will increase the speed of the puck, giving your"
PRINT TAB(16); "opponent less time to respond."
PRINT
PRINT TAB(16); "Completing the word as late as possible will send the puck"
PRINT TAB(16); "at an angle, which gives your opponent a longer word."
PRINT
PRINT TAB(3); "DISCLAIMER: Playing this game for long periods may cause RSI."

PRINT: PRINT: PRINT
PRINT TAB(28); "Please press the any key."
SLEEP
CLS

END SUB

FUNCTION timediff! (earlier AS SINGLE, later AS SINGLE)
IF earlier > later THEN timediff = later - earlier + 86400 ELSE timediff = later - earlier
END FUNCTION

Posted on Feb 18, 2010, 12:32 AM

Respond to this message