'REVISED RND GAME DEFINT A-Z RANDOMIZE TIMER CLS DIM pa AS STRING, na AS STRING DIM dnum AS STRING, g AS INTEGER, difficulty(4) AS INTEGER difficulty(1) = 50 difficulty(2) = 150 difficulty(3) = 300 difficulty(4) = 500 FOR i = 1 TO 11 READ c1, y, x, q$, slp GOSUB display SELECT CASE i CASE 3: CLS CASE 7: IF VAL(inpt$(2)) < 1 OR VAL(inpt$(2)) > 4 THEN GOSUB redo CASE 8: IF rndnum% = 0 THEN rndnum% = INT(RND * difficulty(VAL(inpt$(2)))) + 1 CASE 9 CLS SELECT CASE VAL(inpt$(3)) CASE IS > rndnum% LOCATE 14, 20 PRINT "SORRY " + inpt$(1) + " TOO HIGH!!": SLEEP 2: CLS : GOSUB redo CASE IS < rndnum% LOCATE 14, 20 PRINT "SORRY " + inpt$(1) + " TOO LOW!!": SLEEP 2: CLS : GOSUB redo END SELECT CASE 11: IF UCASE$(inpt$(4)) = "Y" THEN RUN END SELECT NEXT CLS END 'end of program display: COLOR c1 LOCATE y, x SELECT CASE q$ CASE "x-60": q$ = SPACE$(60) CASE "x-p": q$ = " Okay " + inpt$(1) + " I'm thinking of a number between 1 and " + LTRIM$(STR$(difficulty(VAL(inpt$(2))))) + ".." CASE "x-win": q$ = " YOOOU WIIIN " + inpt$(j) + "!!!" END SELECT PRINT q$; SELECT CASE slp CASE 0: j = j + 1: INPUT inpt$(j) CASE ELSE: PRINT : SLEEP slp: key$ = INKEY$ END SELECT RETURN redo: i = i - 2 j = j - 1 RESTORE datax FOR h = 1 TO i READ c1, y, x, q$, slp NEXT h RETURN datax: DATA 7,12,30,Welcome toooo the..,1 DATA 7,13,30,..........,1 DATA 4,14,30,GUESS THE NUMBER GAAAME!!!,2 DATA 4,14,25,Please enter your name..,0 DATA 9,14,20,x-60,1 DATA 9,14,20,What game level would you like (1-4),0 DATA 9,14,20,x-60,1 DATA 4,14,20,x-p,2 DATA 9,16,20,What is my number??,0 DATA 14,13,30,x-win,3 DATA 9,13,25,"Would you like to play again (Y/N)",0 ----------------------------------------- Posted just for fun, yours works fine, although you should remember that you don't need a space in front of a variable, the program automatically ads a space in front of a number. It does so in case there is a minus sign. Also if the num > 0 and num < 5 works for numbers 1, 2, 3, and 4 instead of <br> lev > 0 OR lev >= 1 OR lev <= 4. Also IF num < 0 OR num > 4 works for the numbers 1, 2, 3, and 4, also. My example isn't very straight forward. Mostly it shows what can be done with arrays and DATA statements to shorten repeated statements in a program. I didn't take the time to comment the code. I've been short on time lately and I'm actually getting behind on things by coding again. Anyway, I thought it might be fun for you to see how programs can be coded differently and still achieve the same results. Nice job on finishing your project, Pete
|