commit e12d9bd75d6224c80d221f27f7ae7c6b65bb8a6f parent f324268afd3f07299321917de975cf59bca32cbd Author: bsandro <brian.drosan@gmail.com> Date: Sat, 14 Nov 2020 23:25:19 +0300 exit via Q or Esc Diffstat:
M | ebitest.go | | | 6 | ++++++ |
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/ebitest.go b/ebitest.go @@ -11,6 +11,7 @@ import ( "math" "math/rand" "time" + "errors" ) const S_FRAMERATE = 60 @@ -41,6 +42,11 @@ func (g *Game) Update() error { g.init() } + if ebiten.IsKeyPressed(ebiten.KeyQ) || ebiten.IsKeyPressed(ebiten.KeyEscape) { + // @todo find out if it is possible to gracefully stop the game via ebiten structure + return errors.New("exit") + } + for _, sprite := range g.sprites { err := sprite.Update() if err != nil {