...
This commit is contained in:
parent
a3d7939d0e
commit
b5ca8bef88
3 changed files with 19 additions and 2 deletions
|
@ -52,5 +52,8 @@ func main() {
|
|||
e.Add(tri)
|
||||
fmt.Println(rect.GetLayer(), player.GetLayer())
|
||||
|
||||
e.Run()
|
||||
err = e.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@ func NewPlayer() *Player {
|
|||
return ret
|
||||
}
|
||||
|
||||
func (p *Player) Start(c *Context) {
|
||||
fmt.Println("library:", c.GraphicsLibrary())
|
||||
}
|
||||
|
||||
// Custom drawing function.
|
||||
func (p *Player) Draw(c *Context) {
|
||||
p.Sprite.Draw(c)
|
||||
|
|
12
engine.go
12
engine.go
|
@ -10,6 +10,9 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
type GraphicsLibrary = ebiten.GraphicsLibrary
|
||||
type RunOptions = ebiten.RunGameOptions
|
||||
|
||||
// The type represents order of drawing.
|
||||
// Higher values are drawn later.
|
||||
type Layer float64
|
||||
|
@ -20,6 +23,8 @@ func (l Layer) GetLayer() Layer {
|
|||
|
||||
// Window configuration type.
|
||||
type WindowConfig struct {
|
||||
DebugInfo ebiten.DebugInfo
|
||||
Options *RunOptions
|
||||
// The title of the window.
|
||||
Title string
|
||||
|
||||
|
@ -68,6 +73,10 @@ func (e *Engine) Keys() []Key {
|
|||
return e.keys
|
||||
}
|
||||
|
||||
func (e *Engine) GraphicsLibrary() GraphicsLibrary {
|
||||
return e.wcfg.DebugInfo.GraphicsLibrary
|
||||
}
|
||||
|
||||
// Returns currently pressed buttons.
|
||||
func (e *Engine) MouseButtons() []MouseButton {
|
||||
ret := make([]MouseButton, len(e.buttons))
|
||||
|
@ -351,6 +360,7 @@ func (e *Engine) DT() Float {
|
|||
}
|
||||
|
||||
func (e *Engine) Run() error {
|
||||
ebiten.ReadDebugInfo(&e.wcfg.DebugInfo)
|
||||
ebiten.SetWindowTitle(e.wcfg.Title)
|
||||
ebiten.SetWindowSize(e.wcfg.Width, e.wcfg.Height)
|
||||
ebiten.SetWindowSizeLimits(1, 1, e.wcfg.Width, e.wcfg.Height)
|
||||
|
@ -359,6 +369,6 @@ func (e *Engine) Run() error {
|
|||
|
||||
e.lastTime = time.Now()
|
||||
//fmt.Println(e.Objects)
|
||||
return ebiten.RunGame((*engine)(e))
|
||||
return ebiten.RunGameWithOptions((*engine)(e), e.wcfg.Options)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue