From 8fd34d0eca149921cf0ddee47d862382f2029dfb Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Wed, 30 May 2012 21:46:48 +0000 Subject: Set the ground and the ball in the center of the screen Make the ground half of the screen size. Signed-off-by: Manuel QuiƱones --- diff --git a/game.py b/game.py index 7ef50ae..cffeefa 100755 --- a/game.py +++ b/game.py @@ -34,18 +34,25 @@ class Ball(object): class Level(object): - def __init__(self, hardness): + def __init__(self, hardness, parent_width, parent_height): + + # FIXME, use the hardness value to make random levels of + # different difficulty self._hardness = hardness + self._parent_width = parent_width + self._parent_height = parent_height + self._rects = [] self._ball_start = None self._ball_end = None self.calculate_level() def calculate_level(self): - rect = pygame.Rect((10, 10), (250, 180)) + rect = pygame.Rect((self._parent_width / 4, self._parent_height / 4), + (self._parent_width / 2, self._parent_height / 2)) self._rects.append(rect) - self._ball_start = 100, 100 - self._ball_end = 200, 150 + self._ball_start = self._parent_width / 2, self._parent_height / 2 + self._ball_end = self._parent_width / 3, self._parent_height / 3 def get_ball_start(self): return self._ball_start @@ -87,7 +94,7 @@ class TiltGame(object): self._screen = None def setup(self): - self._level = Level(0.5) + self._level = Level(0.5, *self._screen.get_size()) ball_x, ball_y = self._level.get_ball_start() self._ball = Ball(ball_x, ball_y) -- cgit v0.9.1