sry.. the delay .. =/
anywhy heres the code :
DIM HighName$(20)
DIM HighTries(20)
Playing = 1
SYNC RATE 30
SYNC ON
SET TEXT TRANSPARENT
WHILE Playing = 1
DisplayTitle()
PlayGame()
Playing = PlayAgain()
ENDWHILE
END
' This function displays the title page for the game
FUNCTION DisplayTitle()
Red = RGB(255,0,0)
White = RGB(255,255,255)
Black = RGB(0,0,0)
INK White,Red
CENTER TEXT 320,10, "Guess My Number"
INK White,Black
CENTER TEXT 320,400, "Press Any Key to Continue"
SYNC
DisplayHighScores()
Counter = 1
WHIlE INKEY$() = ""
Counter = Counter + 1
SYNC
ENDWHILE
RANDOMIZE Counter
WHIlE INKEY$() <> ""
SYNC
ENDWHILE
ENDFUNCTION
' This plays the main game
FUNCTION PlayGame()
MyNumber = RND(1000)
YourNumber = -1
Tries = 0
TempString$ = ""
WHILE YourNumber <> MyNumber
Tries = Tries + 1
CLS
CENTER TEXT 320,10,"I have picked a number between 1 and 1000"
CENTER TEXT 320,22,"You have to guess. I will help you!"
TEXT 10,420,TempString$
SYNC
SET CURSOR 10,400
PRINT "What is your number? ";
INPUT YourNumber
SYNC
IF YourNumber > MyNumber
TempString$ = "My Number is less then that number! (Lower)"
ENDIF
IF YourNumber < MyNumber
TempString$ = "My Number is greater then that number! (Higher)"
ENDIF
IF YourNumber = MyNumber
TempString$ = "You are correct. Way to go"
ENDIF
IF Tries = 5 THEN WRITE TO CLIPBOARD STR$(MyNumber)
ENDWHILE
CLS
CENTER TEXT 320,10,"I have picked a number between 1 and 1000"
CENTER TEXT 320,22,"You have to guess. I will help you!"
TEXT 10,420, TempString$
SYNC
SYNC
SLEEP 1000
HighScore = CheckHighScore(Name$,Tries)
IF HighScore
CLS
CENTER TEXT 320,10,"Congratulations, you have made it into the high scores"
SET CURSOR 10,400
SYNC
INPUT "What is your name? ",Name$
EnterHighScore(Name$,Tries)
ENDIF
ENDFUNCTION
' This checks to see if the player
' want's to play again
FUNCTION PlayAgain()
Flag = 0
CLS
CENTER TEXT 320,240,"Would you like to play again? Y/N"
SYNC
Answer$ = AskYesNo$()
IF Answer$ = "YES" THEN Flag = 1
ClS
SYNC
ENDFUNCTION Flag
' This function displays the highscores
FUNCTION DisplayHighScores()
CENTER TEXT 320,30,"High Scores"
CENTER TEXT 160,50,"Names"
CENTER TEXT 480,50,"Tries"
CENTER TEXT 160,68,"___"
CENTER TEXT 480,68,"___"
IF FILE EXIST("HIGHSCORE.DAT") = 0 THEN EXITFUNCTION
OPEN TO READ 1, "HIGHSCORE.DAT"
ypos = 80
FOR x = 1 TO 20
READ STRING 1, Name$
READ LONG 1, Tries
IF Tries <> 0
CENTER TEXT 160,ypos,Name$
CENTER TEXT 480,ypos,STR$(Tries)
ENDIF
ypos = ypos + 12
NEXT x
CLOSE FILE 1
ENDFUNCTION
' This function records a new highscore
FUNCTION EnterHighScore(Name$,Tries)
IF FILE EXIST("HIGHSCORE.DAT") = 0
OPEN TO WRITE 1,"HIGHSCORE.DAT"
WRITE STRING 1, LEFT$(Name$,20)
WRITE LONG 1,Tries
FOR X = 2 TO 20
WRITE STRING 1," "
WRITE LONG 1,0
NEXT X
CLOSE FILE 1
EXITFUNCTION
ENDIF
OPEN TO READ 1,"HIGHSCORE.DAT"
FOR X = 1 TO 20
READ STRING 1,a$
HighName$(X) = a$
READ LONG 1, a
HighTries(X) = a
NEXT X
CLOSE FILE 1
strtoplace$ = Name$
numtoplace = Tries
FOR x = 1 TO 20
IF HighTries(x) >= numtoplace OR HighTries(x) = 0
tempstr$ = HighName$(x)
tempnum = HighTries(x)
HighName$(x) = strtoplace$
HighTries(x) = numtoplace
strtoplace$ = tempstr$
numtoplace = tempnum
ENDIF
NEXT X
DELETE FILE "HIGHSCORE.DAT"
OPEN TO WRITE 1, "HIGHSCORE.DAT"
FOR X = 1 TO 20
WRITE STRING 1, HighName$(X)
WRITE LONG 1, HighTries(X)
NEXT X
CLOSE FILE 1
ENDFUNCTION
' This function checks to see if a highscore
' qualifies.
FUNCTION CheckHighScore(Name$,Tries)
IF FILE EXIST("HIGHSCORE.DAT") = 1
EXITFUNCTION 1
ENDIF
OPEN TO READ 1,"HIGHSCORE.DAT"
FOR X = 1 TO 20
READ STRING 1,a$
HighName$(X) = a$
READ LONG 1, a
HighTries(X) = a
NEXT X
CLOSE FILE 1
Flag = 0 FOR
X = 1 TO 20
IF HighTries(x) >= Tries OR HighTries(x) = 0
Flag = 1
ENDIF
NEXT X
ENDFUNCTION Flag
' This waits for a Y/N key
FUNCTION AskYesNo$
ch$ = UPPER$(INKEY$())
WHILE ch$ <> "Y" AND ch$ <> "N"
ch$ = UPPER$(INKEY$())
SYNC
ENDWHILE
IF ch$ = "Y" then Ret$ = "YES"
IF ch$ = "N" then Ret$ = "NO"
WHILE ch$ = "Y" OR ch$ = "N"
ch$ = UPPER$(INKEY$())
SYNC
ENDWHILE
ENDFUNCTION Ret$