diff options
author | Pootle daemon <pootle@pootle.sugarlabs.org> | 2012-11-17 21:20:33 (GMT) |
---|---|---|
committer | Pootle daemon <pootle@pootle.sugarlabs.org> | 2012-11-17 21:20:33 (GMT) |
commit | dd2149fa1c16ddce780f2774cccf05a2b00af8b3 (patch) | |
tree | b65754b0ca81866e0cb9dc563dc649f218de5f9a /game.py | |
parent | 89b4f57449d44595788b50ab2e7d51fe2b4f1773 (diff) | |
parent | 67ca642a612b7637ff26a87f962ee0dfb7081d23 (diff) |
Merge branch 'master' of git.sugarlabs.org:nutrition/nutrition
Diffstat (limited to 'game.py')
-rw-r--r-- | game.py | 32 |
1 files changed, 21 insertions, 11 deletions
@@ -161,28 +161,38 @@ class Game(): card_list[i].set_margins(10, 0, 10, 0) card_list[i].hide() - def picture_append(self, path, i): - self._picture_cards[i] = Sprite( + def picture_append(self, path, i=-1): + spr = Sprite( self._sprites, int(self._width / 2.), int(self._height / 4.), GdkPixbuf.Pixbuf.new_from_file_at_size( path, int(self._width / 3.), int(9 * self._width / 12.))) + if i == -1: + self._picture_cards.append(spr) + else: + self._picture_cards[i] = spr self._picture_cards[i].type = 'picture' self._picture_cards[i].hide() - def small_picture_append(self, path, i): + def small_picture_append(self, path, i=-1): x = int(self._width / 3.) y = int(self._height / 6.) + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size( + path, + int(self._width / 6.), + int(3 * self._width / 8.)) for j in range(6): # up to 6 of each card - self._small_picture_cards[i * 6 + j] = Sprite( - self._sprites, x, y, - GdkPixbuf.Pixbuf.new_from_file_at_size( - path, - int(self._width / 6.), - int(3 * self._width / 8.))) - self._small_picture_cards[i * 6 + j].type = 'picture' - self._small_picture_cards[i * 6 + j].hide() + if i == -1: + self._small_picture_cards.append(Sprite( + self._sprites, x, y, pixbuf)) + self._small_picture_cards[-1].type = 'picture' + self._small_picture_cards[-1].hide() + else: + self._small_picture_cards[i * 6 + j] = Sprite( + self._sprites, x, y, pixbuf) + self._small_picture_cards[i * 6 + j].type = 'picture' + self._small_picture_cards[i * 6 + j].hide() x += int(self._width / 6.) if j == 2: x = int(self._width / 3.) |