Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/game.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-01-05 19:32:12 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-01-05 19:32:12 (GMT)
commit7b9d943a901c549e7563b521d40ed560d0f05c94 (patch)
tree951a6a7a01e4a4dfc3331b3da1ab9d79c8b43bd8 /game.py
parent98beace4327c0862c4ab2b7952e6285a62adef76 (diff)
click the cookie in cookie monster's mouth to indicate a cookie is there
Diffstat (limited to 'game.py')
-rw-r--r--game.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/game.py b/game.py
index 1e24165..64f7770 100644
--- a/game.py
+++ b/game.py
@@ -192,14 +192,15 @@ class Game():
if event.button > 1:
if spr.type != 0:
- if spr.type in [1, 2]:
- spr.set_shape(self._new_dot(self._colors[2]))
- spr.type += 2
- else: # elif spr.type in [3, 4]:
- spr.set_shape(self._new_dot(self._colors[1]))
- spr.type -= 2
- self._test_game_over()
+ self._flip_the_cookie(spr)
return True
+ else:
+ if spr.type != 0:
+ red, green, blue, alpha = spr.get_pixel((x, y))
+ _logger.debug('red %d' % (red))
+ if red > 40 and red < 240: # touched the cookie
+ self._flip_the_cookie(spr)
+ return True
if spr.type in [2, 4]:
spr.set_shape(self._new_dot(self._colors[4]))
@@ -212,6 +213,15 @@ class Game():
return True
+ def _flip_the_cookie(self, spr):
+ if spr.type in [1, 2]:
+ spr.set_shape(self._new_dot(self._colors[2]))
+ spr.type += 2
+ else: # elif spr.type in [3, 4]:
+ spr.set_shape(self._new_dot(self._colors[1]))
+ spr.type -= 2
+ self._test_game_over()
+
def remote_button_press(self, dot, color):
''' Receive a button press from a sharer '''
self._dots[dot].type = color