mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
Refactoring
This commit is contained in:
parent
75b1c850a1
commit
2794c70388
@ -16,15 +16,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type UI struct {
|
type UI struct {
|
||||||
screenWidth int
|
screenWidth int
|
||||||
screenHeight int
|
screenHeight int
|
||||||
screenScale int
|
screenScale int
|
||||||
title string
|
title string
|
||||||
initializing chan ebiten.Game
|
initializing chan ebiten.Game
|
||||||
initialized chan ebiten.Game
|
initialized chan ebiten.Game
|
||||||
updating chan ebiten.Game
|
updating chan ebiten.Game
|
||||||
updated chan ebiten.Game
|
updated chan ebiten.Game
|
||||||
input chan ebiten.InputState
|
input chan ebiten.InputState
|
||||||
|
graphicsDevice *opengl.Device
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentUI *UI
|
var currentUI *UI
|
||||||
|
5
ui/ui.go
5
ui/ui.go
@ -17,6 +17,9 @@ type UI interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mainLoop(ui UI, game ebiten.Game) {
|
func mainLoop(ui UI, game ebiten.Game) {
|
||||||
|
ui.Initializing() <- game
|
||||||
|
game = <-ui.Initialized()
|
||||||
|
|
||||||
frameTime := time.Duration(int64(time.Second) / int64(ebiten.FPS))
|
frameTime := time.Duration(int64(time.Second) / int64(ebiten.FPS))
|
||||||
tick := time.Tick(frameTime)
|
tick := time.Tick(frameTime)
|
||||||
gameContext := &GameContext{
|
gameContext := &GameContext{
|
||||||
@ -24,8 +27,6 @@ func mainLoop(ui UI, game ebiten.Game) {
|
|||||||
screenHeight: ui.ScreenHeight(),
|
screenHeight: ui.ScreenHeight(),
|
||||||
inputState: ebiten.InputState{-1, -1},
|
inputState: ebiten.InputState{-1, -1},
|
||||||
}
|
}
|
||||||
ui.Initializing() <- game
|
|
||||||
game = <-ui.Initialized()
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case gameContext.inputState = <-ui.Input():
|
case gameContext.inputState = <-ui.Input():
|
||||||
|
Loading…
Reference in New Issue
Block a user