mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58: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) {
|
||||
t := b.tasks[0]
|
||||
err := t()
|
||||
if err == taskTerminated {
|
||||
if err := t(); err == taskTerminated {
|
||||
b.tasks = b.tasks[1:]
|
||||
} else if err != nil {
|
||||
return err
|
||||
@ -103,7 +102,7 @@ func (b *Board) Move(dir Dir) error {
|
||||
})
|
||||
b.tasks = append(b.tasks, func() error {
|
||||
for t := range b.tiles {
|
||||
if t.isPopping() {
|
||||
if t.isAnimating() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ func (t *Tile) IsMoving() bool {
|
||||
return 0 < t.movingCount
|
||||
}
|
||||
|
||||
func (t *Tile) isPopping() bool {
|
||||
return 0 < t.poppingCount
|
||||
func (t *Tile) isAnimating() bool {
|
||||
return 0 < t.movingCount || 0 < t.startPoppingCount || 0 < t.poppingCount
|
||||
}
|
||||
|
||||
func tileAt(tiles map[*Tile]struct{}, x, y int) *Tile {
|
||||
|
Loading…
Reference in New Issue
Block a user