diff --git a/internal/driver/ui.go b/internal/driver/ui.go index d18d7aacc..aadb43da1 100644 --- a/internal/driver/ui.go +++ b/internal/driver/ui.go @@ -17,8 +17,13 @@ package driver import ( "errors" "image" + "time" ) +// IsPlayground indicates whether the current environment is the Go Playground (play.golang.org) or not. +// The fixed time is explicitly defined. See "About the Playground" at play.golang.org. +var IsPlayground = time.Now().UnixNano() == 1257894000000000000 + type UIContext interface { SetSize(width, height int, scale float64) Update(afterFrameUpdate func()) error diff --git a/internal/graphicsdriver/graphicsdriver_playground.go b/internal/graphicsdriver/graphicsdriver_playground.go index 38a7b9798..6130d8f8f 100644 --- a/internal/graphicsdriver/graphicsdriver_playground.go +++ b/internal/graphicsdriver/graphicsdriver_playground.go @@ -27,7 +27,7 @@ import ( ) func Get() driver.Graphics { - if !isPlayground { + if !driver.IsPlayground { panic("ebiten: a graphics driver is not implemented on this environment") } // TODO: Implement this diff --git a/internal/uidriver/uidriver_playground.go b/internal/uidriver/uidriver_playground.go index d56110fa9..07300655a 100644 --- a/internal/uidriver/uidriver_playground.go +++ b/internal/uidriver/uidriver_playground.go @@ -27,7 +27,7 @@ import ( ) func Get() driver.UI { - if !isPlayground { + if !driver.IsPlayground { panic("ebiten: a UI driver is not implemented on this environment") } // TODO: Implement this diff --git a/run.go b/run.go index 2db3df130..bbb5e7fd0 100644 --- a/run.go +++ b/run.go @@ -17,7 +17,6 @@ package ebiten import ( "image" "sync/atomic" - "time" "github.com/hajimehoshi/ebiten/internal/clock" "github.com/hajimehoshi/ebiten/internal/driver" @@ -28,10 +27,6 @@ import ( var _ = __EBITEN_REQUIRES_GO_VERSION_1_12_OR_LATER__ -// isPlayground indicates whether the current environment is the Go Playground (play.golang.org) or not. -// The fixed time is explicitly defined. See "About the Playground" at play.golang.org. -var isPlayground = time.Now().UnixNano() == 1257894000000000000 - // TPS represents a default ticks per second, that represents how many times game updating happens in a second. const DefaultTPS = 60