diff options
author | Joop Kiefte <ikojba@gmail.com> | 2020-08-27 04:04:33 +0200 |
---|---|---|
committer | Joop Kiefte <ikojba@gmail.com> | 2020-08-27 04:04:33 +0200 |
commit | e7099a6f597f227cf141f621e28dcc2acf64fdf3 (patch) | |
tree | 18c5820d4c683142fb18c5dc897b49c222fca21e |
Initial commit
-rw-r--r-- | go.mod | 3 | ||||
-rw-r--r-- | main.go | 61 |
2 files changed, 64 insertions, 0 deletions
@@ -0,0 +1,3 @@ +module git.kiefte.eu/lapingvino/clitris + +go 1.15 @@ -0,0 +1,61 @@ +package main + +import ( + "fmt" + "time" +) + +type Piece int + +const ( + IPiece Piece = iota + JPiece + LPiece + SPiece + ZPiece + TPiece + OPiece +) + +type Field [20][10]bool + +func (f Field) String() (output string) { + var toprow [10]bool + var top bool + for _, row := range f { + top = !top + for i, block := range row { + if top { + toprow[i] = block + continue + } + switch { + case toprow[i] && block: + output += "\u2588" + case toprow[i] && !block: + output += "\u2580" + case !toprow[i] && block: + output += "\u2584" + default: + output += " " + } + } + if !top { + output += "\n" + } + } + return output +} + +func main() { + var f Field + fmt.Print("\033[2J") // Clear screen + for i := 0; i < 200; i++ { + if (i+i/10)%2 == 0 { + f[i/10][i%10] = true + } + fmt.Print("\033[0;0H") // Position to 0,0 + fmt.Println(f.String()) + time.Sleep(time.Second/1000) + } +} |