Fixes #4, additional debug

This commit is contained in:
Sacha Ligthert 2023-12-04 01:01:45 +01:00
parent 9aad81f7cd
commit 2e13d93a53
2 changed files with 20 additions and 14 deletions

28
game.go
View File

@ -87,7 +87,7 @@ func (game *Game) gameDirector() {
game.drawScore()
game.drawPlayer()
//game.drawCoords()
//game.drawDebug()
game.drawDebug()
// Draw robots??
if len(game.robots) == 0 {
@ -169,21 +169,27 @@ func quit(game *Game) {
}
func (game *Game) randPos() Position {
var safe bool = false
//var safe bool = false
var pos Position
for !safe {
x := rand.Intn(80)
y := rand.Intn(24)
// for !safe {
// x := rand.Intn(80)
// y := rand.Intn(24)
// if x == 0 || x == 79 || y == 0 || y == 23 {
// safe = false
// } else {
// pos.x = x
// pos.y = y
// safe = true
// }
// }
x := 1 + rand.Intn(77)
y := 1 + rand.Intn(22)
if x == 0 || x == 79 || y == 0 || y == 23 {
safe = false
} else {
pos.x = x
pos.y = y
safe = true
}
}
return pos
}

View File

@ -52,7 +52,7 @@ func (game *Game) drawCoords() {
func (game *Game) drawDebug() {
var x, y int = 40, 24
for _, r := range []rune("[ NumGoRoutine: " + strconv.FormatInt(int64(runtime.NumGoroutine()), 10) + " ]") {
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++
}