From 91947f614c21af1cb8069ecdc5f139d0977a8ffb Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 6 Jun 2020 18:45:15 +0100 Subject: [PATCH] Randomly position new rovers --- pkg/game/world.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/game/world.go b/pkg/game/world.go index 7a6a7f2..a88282c 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -44,13 +44,20 @@ func (w *World) SpawnRover() uuid.UUID { Speed: 1.0, Range: 20.0, - Pos: Vector{}, // Set the name randomly Name: babble.NewBabbler().Babble(), }, } + // Spawn in a random place near the origin + rover.Attributes.Pos = Vector{ + 10 - (rand.Int() % 20), + 10 - (rand.Int() % 20), + } + + // TODO: Verify no blockages in this area + // Append the rover to the list w.Rovers[rover.Id] = rover