Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/grid.py
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2009-11-03 15:02:41 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2009-11-03 15:02:41 (GMT)
commit43add4f1be6d04cb7afb63012bc169e0bd7d385a (patch)
treef1e216638edeecd6e7fafe752273b5fbdf488674 /grid.py
parent63d383e85829d80478a53563deaeeff6a86af80d (diff)
added reset functionality
Diffstat (limited to 'grid.py')
-rw-r--r--grid.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/grid.py b/grid.py
index e1f93f0..69db46f 100644
--- a/grid.py
+++ b/grid.py
@@ -40,7 +40,7 @@ class Grid:
# 345
# 678
# 9 is an extra (blank) card that matches everything
- def __init__(self,tw):
+ def __init__(self, tw):
self.grid = [0,1,2,3,4,5,6,7,8,9]
self.card_table = {}
# stuff to keep around for the graphics
@@ -63,8 +63,15 @@ class Grid:
if i == 9: # put the extra (blank) card off the screen
y = self.h
+ # reset everything to initial layout
+ def reset(self, tw):
+ self.set_grid([0,1,2,3,4,5,6,7,8,9])
+ self.set_orientation([0,0,0,0,0,0,0,0,0,0])
+ for i in range(9):
+ self.card_table[i].reload_image(tw, i)
+
# force a specific layout
- def set_grid(self,newgrid):
+ def set_grid(self, newgrid):
x = int((self.w-(self.d*3*self.s))/2)
y = int((self.h-(self.d*3*self.s))/2)
for c in newgrid:
@@ -78,9 +85,9 @@ class Grid:
x = int((self.w-(self.d*3*self.s))/2)
y += int(self.d*self.s)
- def set_orientation(self,neworientation):
+ def set_orientation(self, neworientation):
for c in range(9):
- self.card_table[c].set_orientation(neworientation[c])
+ self.card_table[c].set_orientation(neworientation[c],True)
self.card_table[c].draw_card()
# swap in/out the blank card
@@ -89,7 +96,7 @@ class Grid:
# swap card a and card b
# swap their entries in the grid and the position of their sprites
- def swap(self,a,b):
+ def swap(self, a, b):
self.print_grid()
print a, b
# swap grid elements and x,y positions of sprites