better time handling

This commit is contained in:
Baipyrus 2024-04-14 22:00:37 +02:00
parent 3403886e48
commit 6e88f0f750

View File

@ -61,11 +61,12 @@ func initGrid(width, height int, parent ...[][]Cell) ([][]Cell, error) {
var grid [][]Cell 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) grid, _ = initGrid(width, height)
// Prepare ticker and finishing flag // Prepare ticker and finishing flag
ticker := time.NewTicker(time.Second / time.Duration(FPS)) ticker := time.NewTicker((1000 / FPS) * time.Millisecond)
done := make(chan bool) done := make(chan bool)
// Run game loop // Run game loop