Coolbasic
//the Ultimate Guessing Game (is that name proper English?)
//By: Jarkko 'Jare' Linnanvirta 2007 (e-mail me if you want to ask something: kpelit2003@hotmail.com)
//Can be used freely.
'The very important title
SetWindow "the Ultimate Guessing Game!"
'Start by randomizing a number
theNumber = Rand(1,100)
Repeat
Text 0,0, "Guess what number I am thinking (1 - 100)"
'Show console for user's ansrver
Locate 0, ScreenHeight()-20
ansver = Input("? ")
'Check ansver when user hit's enter
If KeyHit(cbKeyReturn) Then
times + 1
If ansver = theNumber Then
'User got it right
Text 0,20, "Yes, that's what I was thinking!"
Text 0,40, "You tried "+times+" times."
DrawScreen
WaitKey
theNumber = Rand(1,100)
times = 0
ElseIf ansver < theNumber Then
'User got it wrong
Text 0,20, "No, too low!"
DrawScreen
WaitKey
Else
'User got it wrong again
Text 0,20, "No, too high!"
DrawScreen
WaitKey
End If
CloseInput 'Clear ansver in console
End If
DrawScreen 'Update screen so we can see something
Forever 'Eternal loop (of course there is an inbuild safe exit feature: Escape key closes the program)
[[/code]]