diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-04-20 12:52:50 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-04-20 12:52:50 (GMT) |
commit | d115f22ff2210f72a00769549f6710a48e4b3625 (patch) | |
tree | d7af6d9752010ece31382a6ee08c13521c8a2dd7 | |
parent | 12ff5d0dcb57ec104e482bbe7f417b8a0d736985 (diff) |
lock during animations
-rw-r--r-- | game.py | 11 | ||||
-rw-r--r-- | grid.py | 5 |
2 files changed, 16 insertions, 0 deletions
@@ -397,9 +397,19 @@ class Game(): elif self._failure is not None: # Return last card clicked to grid self.clean_up_no_match(spr, share=True) + # Nothing else to do. if spr is None: return True + # Don't grab cards in the match pile. + if spr in self.match_list: + return True + + # Don't grab a card being animated. + if True in self.grid.animation_lock: + _logger.debug('waiting on animation lock') + return True + # We are only interested in cards in the deck. if self.deck.spr_to_card(spr) is not None: self.press = spr @@ -488,6 +498,7 @@ class Game(): else: self.process_click(self.press) elif move == 'abort': + i = self._where_in_clicked(self.press) self.press.move(self.clicked[i].pos) else: # move == 'drag' move = self._process_drag(self.press, x, y) @@ -49,6 +49,7 @@ class Grid: self.ex = [0, 0, 0, 0, 0, 0] self.ey = [0, 0, 0, 0, 0, 0] self.stop_animation = False + self.animation_lock = [False, False, False, False, False, False] def deal(self, deck): ''' Deal an initial set of cards. ''' @@ -124,6 +125,7 @@ class Grid: def return_to_grid(self, spr, i, j): ''' Move card to the match area. ''' self.stop_animation = False + self.animation_lock[j] = True spr.set_layer(2000) self.ex[j] = self.grid_to_xy(i)[0] self.ey[j] = self.grid_to_xy(i)[1] @@ -139,8 +141,10 @@ class Grid: spr.move_relative((self.dx[i], self.dy[i])) if self.stop_animation: spr.move((self.sx[i], self.sy[i])) + self.animation_lock[i] = False elif _distance_squared(spr.get_xy(), (self.ex[i], self.ey[i])) < 200: spr.move((self.ex[i], self.ey[i])) + self.animation_lock[i] = False else: timeout_id = gobject.timeout_add( 100, self._move_to_position, spr, i) @@ -175,6 +179,7 @@ class Grid: (self.ex[animate + 3] - c.spr.get_xy()[0]) / 10) self.dy[animate + 3] = int( (self.ey[animate + 3] - c.spr.get_xy()[1]) / 10) + self.animation_lock[animate + 3] = True timeout_id = gobject.timeout_add(100, self._move_to_position, c.spr, animate + 3) |