Skip to content

Instantly share code, notes, and snippets.

@tomaes tomaes/whatsmore.bas
Last active May 9, 2019

Embed
What would you like to do?
Started as a qb.js experiment, but it so happens that qb.js is a very limited implementation of QBasic. Had to go back to the real thing.
' What's more? (v1.1)
' a quick guesstimation game in QBASIC
' (slightly extended version, won't run in qb.js)
DIM c%(2): cont% = 1: r% = 0: bchar% = 97 '97 = a,b / 48 = 0,1
CLS
RANDOMIZE TIMER
t = TIMER
DO
FOR i = 0 TO 1: c%(i) = 0: NEXT i
r% = r% + 1
br = RND(1)
FOR y = 1 TO 10
FOR x = 1 TO 10
n% = 0
IF RND(1) > br THEN n% = 1
c%(n%) = c%(n%) + 1
PRINT " "; CHR$(bchar% + n%); " ";
NEXT x
PRINT : PRINT
NEXT y
0 PRINT "What's more (" + CHR$(bchar%) + " or " + CHR$(bchar% + 1) + ")";
INPUT k$
k% = ASC(k$) - bchar%
IF k% + 1 > LEN(c%) OR k% < 0 THEN
PRINT "invalid input!"
GOTO 0
END IF
FOR i = 0 TO 1
PRINT CHR$(bchar%+i); ":"; c%(i); " "
IF c%(i) > c%(k%) THEN cont% = 0
NEXT i
PRINT
LOOP WHILE cont% = 1
PRINT "YOUR RUN: "; r%; " ROUNDS(S) in ca."; INT(TIMER - t); " SECONDS TIME!"
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.