瀏覽代碼

Fixes #4, additional debug

Sacha Ligthert 2 年之前
父節點
當前提交
2e13d93a53
共有 2 個文件被更改,包括 20 次插入14 次删除
  1. 19 13
      game.go
  2. 1 1
      render.go

+ 19 - 13
game.go

@@ -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
-		}
-	}
+	// 	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)
+
+	pos.x = x
+	pos.y = y
 
 	return pos
 }

+ 1 - 1
render.go

@@ -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++
 	}