From ad437b110f17addb8229ce8a9967ef62a3f42000 Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Wed, 30 May 2012 22:20:36 +0000 Subject: Move accelerometer display and remove unneeded code Signed-off-by: Manuel QuiƱones --- 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) -- cgit v0.9.1