package main import "strconv" // drawBox Draw the outline of the box the snake can move in func (g *Game) drawBox(game *Game) { x1 := 0 y1 := 0 x2 := 79 y2 := 23 if y2 < y1 { y1, y2 = y2, y1 } if x2 < x1 { x1, x2 = x2, x1 } // 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 head of the snake func (g *Game) drawCoords(game *Game) { 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++ } }