examples/2048: Refactoring

This commit is contained in:
Hajime Hoshi 2016-08-01 01:23:40 +09:00
parent b3cd2000af
commit ced66ff319
2 changed files with 4 additions and 5 deletions

View File

@ -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
}
}

View File

@ -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 {