Initial commit
implemented the game of life variation with hexagonal grid
This commit is contained in:
30
ticker.go
Normal file
30
ticker.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Ticker struct {
|
||||
*time.Ticker
|
||||
}
|
||||
|
||||
func NewTicker(rate int, interval time.Duration) *Ticker {
|
||||
t := &Ticker{
|
||||
Ticker: time.NewTicker(interval / time.Duration(rate)),
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *Ticker) Reset(rate int, interval time.Duration) {
|
||||
t.Ticker.Reset(interval / time.Duration(rate))
|
||||
}
|
||||
|
||||
func (t *Ticker) HasTicked() bool {
|
||||
select {
|
||||
case <-t.C:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user