Example #1
0
 def make_card_animations(self):
     g = self.game
     self.animations = pg.sprite.Group()
     deal_delay = 0
     for i in range(2):
         card = g.deck.draw_card()
         destination = g.current_player_hand.slots[-1]
         dest_x, dest_y = destination.topleft
         dur = get_distance(destination.center, card.pos) * 20 // card.speed
         ani = Animation(x=dest_x, y=dest_y, duration=dur,
                                 delay=deal_delay, round_values=True)
         ani2 = Task(self.play_deal_sound, deal_delay)
         ani3 = Task(self.flip_card, deal_delay + dur, args=(card,))
         g.current_player_hand.cards.append(card)
         if not i % 2:
             g.player.add_slot(g.current_player_hand)
         ani.start(card.rect)
         self.animations.add(ani, ani2, ani3)
         deal_delay += dur
     for i in range(2):
         card = g.deck.draw_card()
         destination = g.dealer.hand.slots[-1]
         dest_x, dest_y = destination.topleft
         dur = get_distance(destination.center, card.pos) * 20 // card.speed
         ani = Animation(x=dest_x, y=dest_y, duration=dur,
                                 delay=deal_delay, round_values=True)
         ani2 = Task(self.play_deal_sound, deal_delay)
         ani.start(card.rect)
         g.dealer.hand.cards.append(card)
         g.dealer.add_slot()
         self.animations.add(ani, ani2)
         if i:
             ani3 = Task(self.flip_card, deal_delay + dur, args=(card,))
             self.animations.add(ani3)
         deal_delay += dur
Example #2
0
 def make_card_animations(self):
     g = self.game
     self.animations = pg.sprite.Group()
     deal_delay = 0
     for i in range(2):
         card = g.deck.draw_card()
         destination = g.current_player_hand.slots[-1]
         dest_x, dest_y = destination.topleft
         dur = get_distance(destination.center, card.pos) * 20 // card.speed
         ani = Animation(x=dest_x,
                         y=dest_y,
                         duration=dur,
                         delay=deal_delay,
                         round_values=True)
         ani2 = Task(self.play_deal_sound, deal_delay)
         ani3 = Task(self.flip_card, deal_delay + dur, args=(card, ))
         g.current_player_hand.cards.append(card)
         if not i % 2:
             g.player.add_slot(g.current_player_hand)
         ani.start(card.rect)
         self.animations.add(ani, ani2, ani3)
         deal_delay += dur
     for i in range(2):
         card = g.deck.draw_card()
         destination = g.dealer.hand.slots[-1]
         dest_x, dest_y = destination.topleft
         dur = get_distance(destination.center, card.pos) * 20 // card.speed
         ani = Animation(x=dest_x,
                         y=dest_y,
                         duration=dur,
                         delay=deal_delay,
                         round_values=True)
         ani2 = Task(self.play_deal_sound, deal_delay)
         ani.start(card.rect)
         g.dealer.hand.cards.append(card)
         g.dealer.add_slot()
         self.animations.add(ani, ani2)
         if i:
             ani3 = Task(self.flip_card, deal_delay + dur, args=(card, ))
             self.animations.add(ani3)
         deal_delay += dur
Example #3
0
 def hit(self, hand):
     """Draw a card from deck and add to hand."""
     self.play_deal_sound()
     self.game.player.add_slot(hand)
     card = self.game.deck.draw_card()
     card.face_up = True
     destination = hand.slots[-1]
     dest_x, dest_y = destination.topleft
     hand.cards.append(card)
     dur = get_distance(destination.center, card.pos) * 20 // card.speed
     ani = Animation(x=dest_x, y=dest_y, duration=dur, round_values=True)
     ani.start(card.rect)
     self.animations.add(ani)
Example #4
0
 def hit(self, hand):
     """Draw a card from deck and add to hand."""
     self.play_deal_sound()
     self.game.player.add_slot(hand)
     card = self.game.deck.draw_card()
     card.face_up = True
     destination = hand.slots[-1]
     dest_x, dest_y = destination.topleft
     hand.cards.append(card)
     dur = get_distance(destination.center, card.pos) * 20 // card.speed
     ani = Animation(x=dest_x, y=dest_y, duration=dur, round_values=True)
     ani.start(card.rect)
     self.animations.add(ani)