diff options
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) |