mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
loop: Simplify update
This commit is contained in:
parent
068bc55ded
commit
b95d714eed
@ -126,20 +126,17 @@ func Run(g GraphicsContext, width, height int, scale float64, title string, fps
|
||||
}
|
||||
|
||||
func (c *runContext) update(g GraphicsContext) error {
|
||||
for {
|
||||
e, err := ui.CurrentUI().Update()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch e := e.(type) {
|
||||
case ui.NopEvent:
|
||||
return nil
|
||||
case ui.ScreenSizeEvent:
|
||||
if err := g.SetSize(e.Width, e.Height, e.ActualScale); err != nil {
|
||||
return err
|
||||
}
|
||||
e.Done <- struct{}{}
|
||||
continue
|
||||
case ui.CloseEvent:
|
||||
return regularTermination{}
|
||||
case ui.RenderEvent:
|
||||
@ -147,11 +144,10 @@ func (c *runContext) update(g GraphicsContext) error {
|
||||
return err
|
||||
}
|
||||
e.Done <- struct{}{}
|
||||
return nil
|
||||
default:
|
||||
panic("not reach")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *runContext) render(g GraphicsContext) error {
|
||||
|
Loading…
Reference in New Issue
Block a user