diff --git a/ui/cocoa/cocoa.go b/ui/cocoa/cocoa.go index 01fafaaa6..f92b6e9ee 100644 --- a/ui/cocoa/cocoa.go +++ b/ui/cocoa/cocoa.go @@ -16,15 +16,16 @@ import ( ) type UI struct { - screenWidth int - screenHeight int - screenScale int - title string - initializing chan ebiten.Game - initialized chan ebiten.Game - updating chan ebiten.Game - updated chan ebiten.Game - input chan ebiten.InputState + screenWidth int + screenHeight int + screenScale int + title string + initializing chan ebiten.Game + initialized chan ebiten.Game + updating chan ebiten.Game + updated chan ebiten.Game + input chan ebiten.InputState + graphicsDevice *opengl.Device } var currentUI *UI diff --git a/ui/ui.go b/ui/ui.go index 71818ad82..fecc166e6 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -17,6 +17,9 @@ type UI interface { } func mainLoop(ui UI, game ebiten.Game) { + ui.Initializing() <- game + game = <-ui.Initialized() + frameTime := time.Duration(int64(time.Second) / int64(ebiten.FPS)) tick := time.Tick(frameTime) gameContext := &GameContext{ @@ -24,8 +27,6 @@ func mainLoop(ui UI, game ebiten.Game) { screenHeight: ui.ScreenHeight(), inputState: ebiten.InputState{-1, -1}, } - ui.Initializing() <- game - game = <-ui.Initialized() for { select { case gameContext.inputState = <-ui.Input():