diff options
author | Joop Kiefte <ikojba@gmail.com> | 2020-09-20 09:31:42 +0200 |
---|---|---|
committer | Joop Kiefte <ikojba@gmail.com> | 2020-09-20 09:31:42 +0200 |
commit | f8ec632ce36fa33aadfb28f515ac585b45118179 (patch) | |
tree | 779c0acddc0a1a1d7c730f32ea128d0d83ccc94c /main.go | |
parent | e238c3df5ead21be7868e649dc405b54793ad4eb (diff) |
Add colors
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -31,11 +31,11 @@ func npos(l, c int, f tris.Field) { } } -func render(r [10]bool, block, empty string) string { +func render(r []int, block, empty string) string { var s string for _, c := range r { - if c { - s += block + if c > 0 { + s += fmt.Sprintf("\033[%dm%s\033[0m", c, block) } else { s += empty } @@ -63,7 +63,7 @@ func main() { rand.Seed(time.Now().UnixNano()) // to start with truly random pieces - var f tris.Field // the playing field (10x20) + f := tris.NewField(20, 10) // the playing field (10x20) var floor, topout, harddrop bool // state machine variables to check special situations // define outside of game loop to avoid accidental resets of position @@ -90,7 +90,7 @@ func main() { slines := fmt.Sprintf("lines %d", linescleared) if !harddrop { fpos(0, 0, f.Add(p)) - var next tris.Field + next := tris.NewField(20, 4) b, next = b.Next(5) npos(0, 24, next) ppos(1, 32, sscore) |