diff options
-rwxr-xr-x | game.py | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -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) |