mobile: Move Game definition to package ebiten

Updates #943
This commit is contained in:
Hajime Hoshi 2019-11-25 00:12:06 +09:00
parent 8f08565488
commit b5d8be96a6
2 changed files with 20 additions and 15 deletions

View File

@ -24,21 +24,7 @@ import (
)
// Game defines necessary functions for a mobile game.
type Game interface {
// Update updates a game by one frame.
Update(*ebiten.Image) error
// Layout accepts a native view size in DP (device-independent pixels) and returns the game's logical screen
// size.
//
// The screen scale is automatically adjusted to fit the view.
//
// Layout is called at an initialization and whenever the view size is changed.
//
// You can return a fixed screen size if you don't care, or you can also return a calculated screen size
// adjusted with the given view size.
Layout(viewWidth, viewHeight int) (screenWidth, screenHeight int)
}
type Game = ebiten.Game
// SetGame sets a mobile game.
//

19
run.go
View File

@ -24,6 +24,25 @@ import (
var _ = __EBITEN_REQUIRES_GO_VERSION_1_12_OR_LATER__
// Game defines necessary functions for a game.
//
// Note: This interface is not used anywhere yet.
type Game interface {
// Update updates a game by one frame.
Update(*Image) error
// Layout accepts a native outside size in DP (device-independent pixels) and returns the game's logical
// screen size.
//
// The screen scale is automatically adjusted to fit the outside.
//
// Layout is called at an initialization and whenever the outside size is changed.
//
// You can return a fixed screen size if you don't care, or you can also return a calculated screen size
// adjusted with the given outside size.
Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
}
// TPS represents a default ticks per second, that represents how many times game updating happens in a second.
const DefaultTPS = 60