From d25f6e5b1fcca8d14d624abcf6a9bba258c89292 Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Fri, 24 Nov 2017 12:25:35 +0100 Subject: [PATCH] Remove rand.Seed() from loop --- examples/games/life/life.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/games/life/life.go b/examples/games/life/life.go index 192792c..a86151d 100644 --- a/examples/games/life/life.go +++ b/examples/games/life/life.go @@ -30,18 +30,24 @@ type Game struct { } func main() { + rand.Seed(time.Now().UnixNano()) + game := Game{} game.Init() + raylib.InitWindow(game.ScreenWidth, game.ScreenHeight, "Conway's Game of Life") raylib.SetTargetFPS(20) + for !raylib.WindowShouldClose() { if game.Playing { game.Update() } + game.Input() game.Draw() } + raylib.CloseWindow() } @@ -61,7 +67,6 @@ func (g *Game) Init() { g.Cells[x][y] = &Cell{} g.Cells[x][y].Position = raylib.NewVector2((float32(x) * squareSize), (float32(y)*squareSize)+1) g.Cells[x][y].Size = raylib.NewVector2(squareSize-1, squareSize-1) - rand.Seed(time.Now().UnixNano()) if rand.Float64() < 0.1 { g.Cells[x][y].Alive = true }