// TODO need to be able to build multiple levels // maybe look at adding a 'R' key during debug to reload/refresh level func BuildLevel(g *tl.Game, w, h, score int) { maze := generateMaze(w, h) l := tl.NewBaseLevel(tl.Cell{}) l.SetOffset(30, 15) g.Screen().SetLevel(l) g.Log("Building level with width %d and height %d", w, h) scoretext := tl.NewText(0, 1, "Pengo", tl.ColorWhite, tl.ColorBlack) g.Screen().AddEntity(scoretext) for i, row := range maze { for j, path := range row { if path == '*' { // check if the iceblock is a wall and set its color to white. var blockcolor = tl.ColorBlue if (i <= 1 || j <= 1) || (i >= 15 || j >= 17) { blockcolor = tl.ColorWhite } l.AddEntity(NewIceBlock(i, j, g, blockcolor)) } else if path == 'P' { // it's Pengo l.AddEntity(NewPengo(i, j, g)) } else if path == 'S' { // it's a Snobee l.AddEntity(NewSnobee(i, j, g)) } // 'R' it's a Diamond iceblock // 's' it's a snobee egg iceblock } } }
func buildLevel(g *tl.Game, w, h, score int) { maze := generateMaze(w, h) l := tl.NewBaseLevel(tl.Cell{}) g.SetLevel(l) g.Log("Building level with width %d and height %d", w, h) scoretext := tl.NewText(0, 1, "Levels explored: "+strconv.Itoa(score), tl.ColorBlue, tl.ColorBlack) g.AddEntity(tl.NewText(0, 0, "Pyramid!", tl.ColorBlue, tl.ColorBlack)) g.AddEntity(scoretext) for i, row := range maze { for j, path := range row { if path == '*' { l.AddEntity(tl.NewRectangle(i, j, 1, 1, tl.ColorWhite)) } else if path == 'S' { l.AddEntity(NewBlock(i, j, tl.ColorRed, g, w, h, score, scoretext)) } else if path == 'L' { l.AddEntity(tl.NewRectangle(i, j, 1, 1, tl.ColorBlue)) } } } }