Remove rand.Seed() from loop
This commit is contained in:
parent
d88163e9b6
commit
d25f6e5b1f
1 changed files with 6 additions and 1 deletions
|
@ -30,18 +30,24 @@ type Game struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
game := Game{}
|
game := Game{}
|
||||||
game.Init()
|
game.Init()
|
||||||
|
|
||||||
raylib.InitWindow(game.ScreenWidth, game.ScreenHeight, "Conway's Game of Life")
|
raylib.InitWindow(game.ScreenWidth, game.ScreenHeight, "Conway's Game of Life")
|
||||||
raylib.SetTargetFPS(20)
|
raylib.SetTargetFPS(20)
|
||||||
|
|
||||||
for !raylib.WindowShouldClose() {
|
for !raylib.WindowShouldClose() {
|
||||||
if game.Playing {
|
if game.Playing {
|
||||||
game.Update()
|
game.Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
game.Input()
|
game.Input()
|
||||||
|
|
||||||
game.Draw()
|
game.Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
raylib.CloseWindow()
|
raylib.CloseWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +67,6 @@ func (g *Game) Init() {
|
||||||
g.Cells[x][y] = &Cell{}
|
g.Cells[x][y] = &Cell{}
|
||||||
g.Cells[x][y].Position = raylib.NewVector2((float32(x) * squareSize), (float32(y)*squareSize)+1)
|
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)
|
g.Cells[x][y].Size = raylib.NewVector2(squareSize-1, squareSize-1)
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
if rand.Float64() < 0.1 {
|
if rand.Float64() < 0.1 {
|
||||||
g.Cells[x][y].Alive = true
|
g.Cells[x][y].Alive = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue