Redo how a string is pushed into an array of runes and then printed. (Closes #11)
This commit is contained in:
parent
feced4cd7f
commit
6d23349e43
22
render.go
22
render.go
@ -9,20 +9,24 @@ import (
|
||||
// drawScore Print the score
|
||||
func drawScore(screen tcell.Screen, style tcell.Style, score *Score) {
|
||||
var x, y int = 5, 24
|
||||
for _, r := range []rune("[ Score: " + strconv.FormatInt(int64(score.score), 10) + " ]") {
|
||||
screen.SetContent(x, y-1, r, nil, style)
|
||||
content := "[ Score: " + strconv.FormatInt(int64(score.score), 10) + " ]"
|
||||
for i := 0; i < len(content); i++ {
|
||||
screen.SetContent(x, y-1, rune(content[i]), nil, style)
|
||||
x++
|
||||
}
|
||||
}
|
||||
|
||||
// drawCoords Print the coordinates of the head of the snake
|
||||
func drawCoords(screen tcell.Screen, style tcell.Style, snake *Snake) {
|
||||
var x, y int = 25, 24
|
||||
for _, r := range []rune("[ x:" + strconv.FormatInt(int64(*&snake.head.x), 10) + " y: " + strconv.FormatInt(int64(*&snake.head.y), 10) + " ]") {
|
||||
screen.SetContent(x, y-1, r, nil, style)
|
||||
x++
|
||||
}
|
||||
}
|
||||
// func drawCoords(screen tcell.Screen, style tcell.Style, snake *Snake) {
|
||||
// var x, y int = 25, 24
|
||||
// var snakex int = *&snake.head.x
|
||||
// var snakey int = *&snake.head.y
|
||||
// content := "[ x:" + strconv.Itoa(snakex) + " y: " + strconv.Itoa(snakey) + " ]"
|
||||
// for i := 0; i < len(content); i++ {
|
||||
// screen.SetContent(x, y-1, rune(content[i]), nil, style)
|
||||
// x++
|
||||
// }
|
||||
// }
|
||||
|
||||
// drawBox Draw the outline of the box the snake can move in
|
||||
func drawBox(s tcell.Screen, style tcell.Style, x1, y1, x2, y2 int) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user