diff options
author | Walter Bender <walter@sugarlabs.org> | 2010-09-09 21:42:40 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2010-09-09 21:42:40 (GMT) |
commit | abe48622d44bbbd0f4e6317c65aa82014e32d3f5 (patch) | |
tree | dbb4cc6b5370943ae56d79954380370a844316d5 | |
parent | 8fbad1ee35a4bf17e8ca41373690e4d0a90e1ffd (diff) |
added rotation to test
-rw-r--r-- | window.py | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -120,7 +120,8 @@ class Game(): self.release = None if self.test() == True: if self.level < 2: - gobject.timeout_add(3000, self.activity.level_cb, None) + gobject.timeout_add(3000, self.activity.change_play_level_cb, + None) return True def _keypress_cb(self, area, event): @@ -155,17 +156,33 @@ class Game(): row = int(i/6) col = i%6 if row > self.bounds[0][0] and row <= self.bounds[0][1]: - if C[self.grid.grid[i]][0] != C[self.grid.grid[i - 6]][1]: + if C[self.grid.grid[i]][rotate_index(0, + self.grid.card_table[self.grid.grid[i]].orientation)] != \ + C[self.grid.grid[i - 6]][rotate_index(1, + self.grid.card_table[self.grid.grid[i - 6]].orientation)]: return False - if C[self.grid.grid[i]][3] != C[self.grid.grid[i - 6]][2]: + if C[self.grid.grid[i]][rotate_index(3, + self.grid.card_table[self.grid.grid[i]].orientation)] != \ + C[self.grid.grid[i - 6]][rotate_index(2, + self.grid.card_table[self.grid.grid[i - 6]].orientation)]: return False if col > self.bounds[2][0] and col <= self.bounds[2][1]: - if C[self.grid.grid[i]][3] != C[self.grid.grid[i - 1]][0]: + if C[self.grid.grid[i]][rotate_index(3, + self.grid.card_table[self.grid.grid[i]].orientation)] != \ + C[self.grid.grid[i - 1]][rotate_index(0, + self.grid.card_table[self.grid.grid[i - 1]].orientation)]: return False - if C[self.grid.grid[i]][2] != C[self.grid.grid[i - 1]][1]: + if C[self.grid.grid[i]][rotate_index(2, + self.grid.card_table[self.grid.grid[i]].orientation)] != \ + C[self.grid.grid[i - 1]][rotate_index(1, + self.grid.card_table[self.grid.grid[i - 1]].orientation)]: return False return True +def rotate_index(index, orientation): + """ Account for orientation when computing an index """ + return (index + int(orientation/90)) % 4 + def distance(start, stop): """ Measure the length of drag between button press and button release. """ dx = start[0] - stop[0] |