func (world *World) TerrainFromMapping(mapping string) { trimmed_mapping := strings.Trim(mapping, "\n\t ") world.Height = strings.Count(trimmed_mapping, "\n") + 1 world.Width = -1 world.Terrain = make([][]goncurses.Char, world.Height, world.Height) var xx, yy int var line string var tile rune for xx, line = range strings.Split(trimmed_mapping, "\n") { if world.Width == -1 { world.Width = len(line) } else if len(line) != world.Width { panic("Inconsistent line lengths in mapping") } world.Terrain[xx] = make([]goncurses.Char, world.Width, world.Width) for yy, tile = range line { world.Terrain[xx][yy] = goncurses.Char(tile) } } }
func main() { s, err := gc.Init() if err != nil { log.Fatal("init:", err) } defer gc.End() // determine color support if !gc.HasColors() { log.Fatal("no color support") } // set background color gc.StartColor() gc.InitPair(1, gc.C_WHITE, gc.C_BLUE) s.ColorOn(1) s.SetBackground(gc.Char(' ') | gc.ColorPair(1)) // blinking, different background color s.AttrOn(gc.A_BLINK) gc.InitPair(2, gc.C_WHITE, gc.C_RED) s.ColorOn(2) s.Print(" Blinking Red ") s.GetChar() }