From 6e88f0f750eeeaa3f283818a71a4d04764445d4a Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sun, 14 Apr 2024 22:00:37 +0200 Subject: [PATCH] better time handling --- conway.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conway.go b/conway.go index 816db99..9429b85 100644 --- a/conway.go +++ b/conway.go @@ -61,11 +61,12 @@ func initGrid(width, height int, parent ...[][]Cell) ([][]Cell, error) { var grid [][]Cell -func setup(callback func([][]Cell), width, height, FPS int) chan bool { +func setup(callback func([][]Cell), width, height int, FPS time.Duration) chan bool { + // Initialize grid grid, _ = initGrid(width, height) // Prepare ticker and finishing flag - ticker := time.NewTicker(time.Second / time.Duration(FPS)) + ticker := time.NewTicker((1000 / FPS) * time.Millisecond) done := make(chan bool) // Run game loop