Guess the number/With feedback: Difference between revisions

Content added Content deleted
No edit summary
mNo edit summary
Line 2,028: Line 2,028:
=={{header|FutureBasic}}==
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
<syntaxhighlight lang="futurebasic">
Short n // We'll just do 1..10
Short n // We'll just do 1..10 to get the idea…


void local fn buildInterface
void local fn buildInterface
Short i
Short i
window 1, @"Guess the number" , ( 0, 0, 340, 120 )
window 1, @"Guess the number", ( 0, 0, 340, 120 )
for i = 1 to 10
for i = 1 to 10
button i,,, fn StringWithFormat(@"%d", i), ( 26 * i, 60, 40, 22 )
button i,,, fn StringWithFormat(@"%d", i), ( 26 * i, 60, 40, 22 )
Line 2,039: Line 2,039:
button 11,,, @"Quit", (38, 10, 95, 32 )
button 11,,, @"Quit", (38, 10, 95, 32 )
button 12,,, @"Again", (200, 10, 95, 32 )
button 12,,, @"Again", (200, 10, 95, 32 )
textlabel 13, @"Guess the number:", (112, 85, 200,22 )
textlabel 13, @"Guess the number:", (112, 85, 200, 22 )
textlabel 14,, (158, 30, 100, 22 ) // Hints here
textlabel 14,, (158, 30, 100, 22 ) // Hints here
filemenu 1 : menu 1, -1, No // Build but disable File menu
filemenu 1 : menu 1, -1, No // Build but disable File menu
Line 2,049: Line 2,049:
button 11, No // Disable Quit button
button 11, No // Disable Quit button
button 12, No // Disable Again button
button 12, No // Disable Again button
n = rnd(10) // Choose a random number
n = rnd(10) // Choose a random number 1..10
for i = 1 to 10 : button i, Yes : next // Enable all numbers
for i = 1 to 10 : button i, Yes : next // Enable all numbers
textlabel 14, @"🔴" // Not found yet
textlabel 14, @"🔴" // Not found yet
Line 2,062: Line 2,062:
if tag == n // Found
if tag == n // Found
textlabel 14, @"🟢"
textlabel 14, @"🟢"
button 11, Yes
button 11, Yes // Enable Quit button
button 12, Yes
button 12, Yes // Enable Again button
else // Give us a hint
else // Give a hint
if tag < n
if tag < n
textlabel 14, @"➡️"
textlabel 14, @"➡️"
Line 2,078: Line 2,078:
end fn
end fn


on dialog fn doDialog
fn buildInterface
fn buildInterface
fn newGame
fn newGame


on dialog fn doDialog
handleevents
handleevents
</syntaxhighlight>
</syntaxhighlight>