Created
January 17, 2012 17:19
-
-
Save bakkdoor/1627583 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fancy | |
# A simple guessing game written in Fancy. | |
amount-guesses = 6 | |
"Welcone to the game!" println | |
random-number = 100 random + 1 | |
amount-guesses downto: 1 do: |remaining-guesses| { | |
"You have #{remaining-guesses} guesses remaining." println | |
guess = Console readln: "Guess a number: " to_i | |
"You guessed #{guess}." println | |
if: (random-number == guess) then: { | |
"You won!" println | |
break | |
} else: { | |
if: (random-number > guess) then: { | |
"Too low." println | |
} else: { | |
"Too high."println | |
} | |
} | |
Console newline | |
} | |
"It was #{random-number}!" println |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment