mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
examples/2048: Refactoring
This commit is contained in:
parent
b3cd2000af
commit
ced66ff319
@ -53,8 +53,7 @@ func (b *Board) Update(input *Input) error {
|
|||||||
}
|
}
|
||||||
if 0 < len(b.tasks) {
|
if 0 < len(b.tasks) {
|
||||||
t := b.tasks[0]
|
t := b.tasks[0]
|
||||||
err := t()
|
if err := t(); err == taskTerminated {
|
||||||
if err == taskTerminated {
|
|
||||||
b.tasks = b.tasks[1:]
|
b.tasks = b.tasks[1:]
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -103,7 +102,7 @@ func (b *Board) Move(dir Dir) error {
|
|||||||
})
|
})
|
||||||
b.tasks = append(b.tasks, func() error {
|
b.tasks = append(b.tasks, func() error {
|
||||||
for t := range b.tiles {
|
for t := range b.tiles {
|
||||||
if t.isPopping() {
|
if t.isAnimating() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,8 @@ func (t *Tile) IsMoving() bool {
|
|||||||
return 0 < t.movingCount
|
return 0 < t.movingCount
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tile) isPopping() bool {
|
func (t *Tile) isAnimating() bool {
|
||||||
return 0 < t.poppingCount
|
return 0 < t.movingCount || 0 < t.startPoppingCount || 0 < t.poppingCount
|
||||||
}
|
}
|
||||||
|
|
||||||
func tileAt(tiles map[*Tile]struct{}, x, y int) *Tile {
|
func tileAt(tiles map[*Tile]struct{}, x, y int) *Tile {
|
||||||
|
Loading…
Reference in New Issue
Block a user