From b5ca8bef88ebd412a94c081d0d9d0b73d6d51e58 Mon Sep 17 00:00:00 2001 From: surdeus Date: Mon, 25 Dec 2023 23:41:12 +0300 Subject: [PATCH] ... --- cmd/test/main.go | 5 ++++- cmd/test/player.go | 4 ++++ engine.go | 12 +++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cmd/test/main.go b/cmd/test/main.go index 7eb5413..52aac05 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -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) + } } diff --git a/cmd/test/player.go b/cmd/test/player.go index 26a8eab..cf6268b 100644 --- a/cmd/test/player.go +++ b/cmd/test/player.go @@ -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) diff --git a/engine.go b/engine.go index 06560d4..d268365 100644 --- a/engine.go +++ b/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) }