Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Last active December 25, 2015 11:39
Show Gist options
  • Save masahitojp/6970908 to your computer and use it in GitHub Desktop.
Save masahitojp/6970908 to your computer and use it in GitHub Desktop.
goでslもどき #gocon Go Conference 2013 autumn
package main
import (
"time"
"fmt"
"strings"
)
// put string at pos(x,y)
func put(x int,y int ,str string) {
fmt.Printf("\033[%d;%dH%s\n", y, x, str)
}
// clear terminal
func clear() {
fmt.Print("\033[2J")
}
func main() {
p := []string {
" ==== ________ ___________ ",
"_D _| |_______/ \\__I_I_____===__|_________| ",
"|(_)--- | H\\________/ | | =|___ ___| _________________ ",
"/ | | H | | | | ||_| |_|| _| \\_____A ",
"| | | H |__--------------------| [___] | =| | ",
"| ________|___H__/__|_____/[][]~\\_______| | -| | ",
"|/ | |-----------I_____I [][] [] D |=======|____|________________________|_ ",
"__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_",
"|/-=|___|| || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| ",
"\\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/",
}
const whiteSpaceNumbers = 40
const putTermMilliSeconds = 50
for l:=0; l < len(p); l++ {
p[l] = strings.Repeat(" ", whiteSpaceNumbers) + p[l]
}
for j:= 0; j < len(p[0]); j++{
clear()
for i := 0; i < len(p); i++ {
if (j < len(p[i])) {
put(0, i+1, p[i][j:len(p[i])])
}
}
time.Sleep(putTermMilliSeconds * time.Millisecond)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment