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
|
// drawScore Print the score
|
||||||
func drawScore(screen tcell.Screen, style tcell.Style, score *Score) {
|
func drawScore(screen tcell.Screen, style tcell.Style, score *Score) {
|
||||||
var x, y int = 5, 24
|
var x, y int = 5, 24
|
||||||
for _, r := range []rune("[ Score: " + strconv.FormatInt(int64(score.score), 10) + " ]") {
|
content := "[ Score: " + strconv.FormatInt(int64(score.score), 10) + " ]"
|
||||||
screen.SetContent(x, y-1, r, nil, style)
|
for i := 0; i < len(content); i++ {
|
||||||
|
screen.SetContent(x, y-1, rune(content[i]), nil, style)
|
||||||
x++
|
x++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// drawCoords Print the coordinates of the head of the snake
|
// drawCoords Print the coordinates of the head of the snake
|
||||||
func drawCoords(screen tcell.Screen, style tcell.Style, snake *Snake) {
|
// func drawCoords(screen tcell.Screen, style tcell.Style, snake *Snake) {
|
||||||
var x, y int = 25, 24
|
// 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) + " ]") {
|
// var snakex int = *&snake.head.x
|
||||||
screen.SetContent(x, y-1, r, nil, style)
|
// var snakey int = *&snake.head.y
|
||||||
x++
|
// 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
|
// 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) {
|
func drawBox(s tcell.Screen, style tcell.Style, x1, y1, x2, y2 int) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user