Created
September 21, 2014 23:47
-
-
Save sureshg/6bae7875923954eec26b to your computer and use it in GitHub Desktop.
Steam Locomotive in go - http://play.golang.org/p/NOycgN2i6b
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
package main | |
import ( | |
"time" | |
"fmt" | |
"strings" | |
) | |
func main() { | |
p := [][][]string { | |
{ | |
{ | |
" (@@) ( ) (@) ( ) @@ () @ O @ O @", | |
" ( )", | |
" (@@@@)", | |
" ( )", | |
"", | |
" (@@@)", | |
}, | |
{ | |
" ( ) (@@) ( ) (@) () @@ O @ O @ O", | |
" (@@@)", | |
" ( )", | |
" (@@@@)", | |
"", | |
" ( )", | |
}, | |
}, | |
{ | |
{ | |
" ==== ________ ___________ ", | |
" _D _| |_______/ \\__I_I_____===__|_________| ", | |
" |(_)--- | H\\________/ | | =|___ ___| _________________ ", | |
" / | | H | | | | ||_| |_|| _| \\_____A ", | |
" | | | H |__--------------------| [___] | =| | ", | |
" | ________|___H__/__|_____/[][]~\\_______| | -| | ", | |
" |/ | |-----------I_____I [][] [] D |=======|____|________________________|_ ", | |
}, | |
}, | |
{ | |
{ | |
"__/ =| o |=-O=====O=====O=====O \\ ____Y___________|__|__________________________|_ ", | |
" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| ", | |
" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ ", | |
}, | |
{ | |
"__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ ", | |
" |/-=|___|=O=====O=====O=====O |_____/~\\___/ |_D__D__D_| |_D__D__D_| ", | |
" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ ", | |
}, | |
{ | |
"__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ ", | |
" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| ", | |
" \\_/ \\O=====O=====O=====O_/ \\_/ \\_/ \\_/ \\_/ \\_/ ", | |
}, | |
{ | |
"__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ ", | |
" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| ", | |
" \\_/ \\_O=====O=====O=====O/ \\_/ \\_/ \\_/ \\_/ \\_/ ", | |
}, | |
{ | |
"__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ ", | |
" |/-=|___|= O=====O=====O=====O|_____/~\\___/ |_D__D__D_| |_D__D__D_| ", | |
" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ ", | |
}, | |
{ | |
"__/ =| o |=-~O=====O=====O=====O\\ ____Y___________|__|__________________________|_ ", | |
" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| ", | |
" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ ", | |
}, | |
}, | |
} | |
x := 80 | |
for _, ll := range p { | |
for _, l := range ll { | |
for n := range l { | |
l[n] = strings.Repeat(" ", x) + l[n] | |
} | |
} | |
} | |
x = 0 | |
for { | |
fmt.Print("\x0c") | |
for _, pp := range p { | |
for _, l := range pp[x % len(pp)] { | |
if x < len(l) { | |
fmt.Println(string(l[x:])) | |
} else { | |
fmt.Println() | |
} | |
} | |
} | |
time.Sleep(time.Second / 20) | |
if x++; x > 165 { | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment