Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
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
parent63d383e85829d80478a53563deaeeff6a86af80d (diff)
added reset functionality
-rw-r--r--card.py5
-rw-r--r--grid.py17
2 files changed, 15 insertions, 7 deletions
diff --git a/card.py b/card.py
index 0f43b02..5991084 100644
--- a/card.py
+++ b/card.py
@@ -50,13 +50,14 @@ class Card:
draw(self.spr)
def load_image(self, file, i, wh):
- # print "loading " + os.path.join(file + str(i) + '.svg') + \
- # " scale: " + str(wh)
return gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(file + \
str(i) + "x" + \
'.svg'), \
int(wh), int(wh))
+ def reload_image(self, tw, i):
+ self.spr.image = self.load_image(tw.path,i,tw.card_dim*tw.scale)
+
def set_orientation(self,r,rotate_spr=True):
while r != self.orientation:
self.rotate_ccw(rotate_spr)
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