package main import ( "runtime" "strconv" ) // drawBox Draw the outline of the box the snake can move in func (game *Game) drawBox() { // Assuming we will always have this x1 := 0 y1 := 0 x2 := 79 y2 := 23 // Fill background for row := y1; row <= y2; row++ { for col := x1; col <= x2; col++ { game.screen.SetContent(col, row, ' ', nil, game.style) } } // Draw borders for col := x1; col <= x2; col++ { game.screen.SetContent(col, y1, '═', nil, game.style) game.screen.SetContent(col, y2, '═', nil, game.style) } for row := y1 + 1; row < y2; row++ { game.screen.SetContent(x1, row, '║', nil, game.style) game.screen.SetContent(x2, row, '║', nil, game.style) } // Only draw corners if necessary if y1 != y2 && x1 != x2 { game.screen.SetContent(x1, y1, '╔', nil, game.style) game.screen.SetContent(x2, y1, '╗', nil, game.style) game.screen.SetContent(x1, y2, '╚', nil, game.style) game.screen.SetContent(x2, y2, '╝', nil, game.style) } } // drawCoords Print the coordinates of the player func (game *Game) drawCoords() { var x, y int = 25, 24 for _, r := range []rune("[ x:" + strconv.FormatInt(int64(game.player.position.x), 10) + " y:" + strconv.FormatInt(int64(game.player.position.y), 10) + " ]") { game.screen.SetContent(x, y-1, r, nil, game.style) x++ } } func (game *Game) drawDebug() { var x, y int = 40, 24 for _, r := range []rune("[ NumGoRoutine: " + strconv.FormatInt(int64(runtime.NumGoroutine()), 10) + " Bots: " + strconv.FormatInt(int64(len(game.robots)), 10) + " ]") { game.screen.SetContent(x, y-1, r, nil, game.style) x++ } } func (game *Game) drawScore() { var x, y int = 5, 24 for _, r := range []rune("[ Score: " + strconv.FormatInt(int64(game.player.score), 10) + " Level: " + strconv.FormatInt(int64(game.level), 10) + " ]") { game.screen.SetContent(x, y-1, r, nil, game.style) x++ } }