mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08: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 {
|
func (c *runContext) update(g GraphicsContext) error {
|
||||||
for {
|
|
||||||
e, err := ui.CurrentUI().Update()
|
e, err := ui.CurrentUI().Update()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
switch e := e.(type) {
|
switch e := e.(type) {
|
||||||
case ui.NopEvent:
|
case ui.NopEvent:
|
||||||
return nil
|
|
||||||
case ui.ScreenSizeEvent:
|
case ui.ScreenSizeEvent:
|
||||||
if err := g.SetSize(e.Width, e.Height, e.ActualScale); err != nil {
|
if err := g.SetSize(e.Width, e.Height, e.ActualScale); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
e.Done <- struct{}{}
|
e.Done <- struct{}{}
|
||||||
continue
|
|
||||||
case ui.CloseEvent:
|
case ui.CloseEvent:
|
||||||
return regularTermination{}
|
return regularTermination{}
|
||||||
case ui.RenderEvent:
|
case ui.RenderEvent:
|
||||||
@ -147,11 +144,10 @@ func (c *runContext) update(g GraphicsContext) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
e.Done <- struct{}{}
|
e.Done <- struct{}{}
|
||||||
return nil
|
|
||||||
default:
|
default:
|
||||||
panic("not reach")
|
panic("not reach")
|
||||||
}
|
}
|
||||||
}
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *runContext) render(g GraphicsContext) error {
|
func (c *runContext) render(g GraphicsContext) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user