Fix a SIGSEGV
This commit is contained in:
@@ -7,6 +7,7 @@ package ordoor
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
@@ -29,6 +30,7 @@ type Ordoor struct {
|
|||||||
|
|
||||||
// Relevant to interface state
|
// Relevant to interface state
|
||||||
flow *flow.Flow
|
flow *flow.Flow
|
||||||
|
flowOnce sync.Once
|
||||||
|
|
||||||
// FIXME: should be put inside flow
|
// FIXME: should be put inside flow
|
||||||
// If this is set, we display it instead of flow
|
// If this is set, we display it instead of flow
|
||||||
@@ -178,6 +180,7 @@ func (o *Ordoor) Update(screenX, screenY int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *Ordoor) Draw(screen *ebiten.Image) error {
|
func (o *Ordoor) Draw(screen *ebiten.Image) error {
|
||||||
|
|
||||||
if pic := o.pic; pic != nil {
|
if pic := o.pic; pic != nil {
|
||||||
// Scale the picture to the screen and draw it
|
// Scale the picture to the screen and draw it
|
||||||
scaleX := float64(screen.Bounds().Dx()) / float64(pic.Bounds().Dx())
|
scaleX := float64(screen.Bounds().Dx()) / float64(pic.Bounds().Dx())
|
||||||
@@ -190,7 +193,11 @@ func (o *Ordoor) Draw(screen *ebiten.Image) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.flow != nil {
|
||||||
return o.flow.Draw(screen)
|
return o.flow.Draw(screen)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil // Draw() may be called before Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Ordoor) Cursor() (*ebiten.Image, *ebiten.DrawImageOptions, error) {
|
func (o *Ordoor) Cursor() (*ebiten.Image, *ebiten.DrawImageOptions, error) {
|
||||||
|
Reference in New Issue
Block a user