Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b5846d7

Browse files
committed
A different winning animation.
1 parent 408027e commit b5846d7

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Demo/tkinter/guido/solitaire.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,14 +580,16 @@ def wincheck(self):
580580
def win(self):
581581
"""Stupid animation when you win."""
582582
cards = []
583-
for s in self.suits:
583+
for s in self.openstacks:
584584
cards = cards + s.cards
585-
if not cards:
586-
return
587-
for i in range(1000):
585+
while cards:
588586
card = random.choice(cards)
589-
dx = random.randint(-50, 50)
590-
dy = random.randint(-50, 50)
587+
cards.remove(card)
588+
self.animatedmoveto(card, self.deck)
589+
590+
def animatedmoveto(self, card, dest):
591+
for i in range(10, 0, -1):
592+
dx, dy = (dest.x-card.x)/i, (dest.y-card.y)/i
591593
card.moveby(dx, dy)
592594
self.master.update_idletasks()
593595

0 commit comments

Comments
 (0)