mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
loop: Refactoring: Create updater struct
This commit is contained in:
parent
eef8289854
commit
4ee0c9b482
18
run.go
18
run.go
@ -65,7 +65,7 @@ type runner struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *runner) Run(width, height int, scale float64, title string) error {
|
func (r *runner) Run(width, height int, scale float64, title string) error {
|
||||||
if err := ui.Run(width, height, scale, title, r); err != nil {
|
if err := ui.Run(width, height, scale, title, &updater{r.g}); err != nil {
|
||||||
if _, ok := err.(*ui.RegularTermination); ok {
|
if _, ok := err.(*ui.RegularTermination); ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -74,16 +74,20 @@ func (r *runner) Run(width, height int, scale float64, title string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runner) SetSize(width, height int, scale float64) {
|
type updater struct {
|
||||||
r.g.SetSize(width, height, scale)
|
g *graphicsContext
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runner) Update() error {
|
func (u *updater) SetSize(width, height int, scale float64) {
|
||||||
return loop.Update(r.g)
|
u.g.SetSize(width, height, scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runner) Invalidate() {
|
func (u *updater) Update() error {
|
||||||
r.g.Invalidate()
|
return loop.Update(u.g)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *updater) Invalidate() {
|
||||||
|
u.g.Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the game.
|
// Run runs the game.
|
||||||
|
Loading…
Reference in New Issue
Block a user