Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-05-30 22:20:36 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-05-30 22:20:36 (GMT)
commitad437b110f17addb8229ce8a9967ef62a3f42000 (patch)
tree8eddb6afbeb62f75c1e7471775ed142ed5a1ef62
parenta0552a111aa70fadc214e10e7b072183cea7f088 (diff)
Move accelerometer display and remove unneeded code
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
-rwxr-xr-xgame.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/game.py b/game.py
index b8fbe3e..afd7aa0 100755
--- a/game.py
+++ b/game.py
@@ -163,26 +163,23 @@ class TiltGame(object):
# Success! Restart
self._ball.set_position(*self._level.get_ball_start())
- # Get the position of the accelerometer
- x, y, z = self.accelerometer.read()
- font = pygame.font.Font(pygame.font.get_default_font(), 18)
- surface_x = font.render('X: %s' % x, True, (0, 0, 0))
- surface_y = font.render('Y: %s' % y, True, (0, 0, 0))
- surface_z = font.render('Z: %s' % z, True, (0, 0, 0))
- self._screen.blit(surface_x, (15, 15))
- self._screen.blit(surface_y, (15, surface_x.get_height() + 15))
- self._screen.blit(surface_z,
- (15, surface_x.get_height() * 2 + 15))
-
- if self._level.is_on_hole(self.ball.get_position()):
- self.ball.set_position(self._level.get_ball_start())
-
if self._level.is_on_ground(self._ball.get_position()):
self._ball.update()
else:
# Fail! Restart
self._ball.set_position(*self._level.get_ball_start())
+ # Get the position of the accelerometer
+ x, y, z = self.accelerometer.read()
+ font = pygame.font.Font(pygame.font.get_default_font(), 18)
+ surface_x = font.render('X: %s' % x, True, (0, 0, 0))
+ surface_y = font.render('Y: %s' % y, True, (0, 0, 0))
+ surface_z = font.render('Z: %s' % z, True, (0, 0, 0))
+ self._screen.blit(surface_x, (15, 15))
+ self._screen.blit(surface_y, (15, surface_x.get_height() + 15))
+ self._screen.blit(surface_z,
+ (15, surface_x.get_height() * 2 + 15))
+
# Clear Display
self._screen.fill(BACKGROUND_COLOR)