Created
August 28, 2020 17:47
-
-
Save guaracy/cc249300c564c5937b746cff9d860163 to your computer and use it in GitHub Desktop.
Animation for the hangman game (CLI on Linux)
This file contains 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
Red [ | |
Title: "Hangman" | |
Date: 25-Aug-2020 | |
Author: @guaracy | |
File: %hangman.red | |
Purpouse: { | |
Just an animation for the hangman game | |
CLI on Linux | |
} | |
] | |
bdparts: [ | |
1 3x9 "O" | |
2 4x9 "|" | |
3 4x8 "/" | |
4 4x10 "\" | |
5 5x8 "/" | |
6 5x10 "\" | |
7 5x7 "_" | |
8 5x11 "_" | |
] | |
cls: does[prin "^[[2J"] | |
gotoLC: func[lc][prin rejoin["^[[" lc/x ";" lc/y "H"]] | |
color: func[c][prin rejoin["^[[" c "m"]] | |
printAT: func[p s][gotoLC p prin s] | |
title: does[ | |
titulo: [ | |
"dP" | |
"88" | |
"88d888b. .d8888b. 88d888b. .d8888b. 88d8b.d8b. .d8888b. 88d888b." | |
"88' `88 88' `88 88' `88 88' `88 88'`88'`88 88' `88 88' `88" | |
"88 88 88. .88 88 88 88. .88 88 88 88 88. .88 88 88" | |
"dP dP `88888P8 dP dP `8888P88 dP dP dP `88888P8 dP dP" | |
" .88" | |
" d8888P" | |
] | |
c: (system/console/size/x - 65) >> 1 | |
l: 5 | |
cls | |
color 31 | |
foreach t titulo [ | |
gotoLC to pair! reduce [l c] | |
print t | |
l: l + 1 | |
] | |
color 37 | |
c: (system/console/size/x - 23) >> 1 | |
l: l + 2 | |
gotoLC to pair! reduce [l c] | |
print "Press enter to continue" | |
ask "" | |
] | |
scaffold: does[ | |
print " ______" | |
print " | / |" | |
print " |/" | |
print " |" | |
print " |" | |
print "_|____________" | |
] | |
hang: func[t][ | |
print t | |
bp: find/skip bdparts t 3 | |
if none? bp [exit] | |
gotoLC bp/2 | |
color 32 | |
prin bp/3 | |
color 37 | |
] | |
die: func[][ | |
pause: 0.05 | |
gotoLC 6x1 | |
print "_|____ ____" | |
print " \ /" | |
printAt 3x8 " | " | |
color 32 | |
printAt 4x8 "_O_" | |
printAt 5x7 " _|_ " | |
color 37 | |
wait pause | |
gotoLC 6x1 | |
print "_|__ __" | |
print " \ /" | |
print " \ /" | |
wait pause | |
printAt 4x8 " | " | |
color 32 | |
printAt 5x8 "_O_" | |
printAt 6x8 "_|_" | |
wait pause | |
printAt 5x8 " O " | |
printAt 6x8 "/|\" | |
printAt 7x8 "/ \" | |
wait pause | |
printAt 5x8 " O " | |
printAt 6x8 "|||" | |
printAt 7x8 "_|_" | |
color 31 | |
gotoLC 12x1 | |
ask "You died!" | |
color 37 | |
] | |
title | |
cls | |
gotoLC 1x1 | |
scaffold | |
repeat t 9 [ | |
gotoLC 12x1 | |
ask "Enter some letter and hit enter: " | |
hang t | |
t: t + 1 | |
] | |
die |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment