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 21:46:48 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-05-30 21:46:48 (GMT)
commit8fd34d0eca149921cf0ddee47d862382f2029dfb (patch)
tree540b616bc373aa1d105ad09349234633cc94c122
parent0267bdbfcabcefaefc0f2c349c9bed0c826a97f9 (diff)
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 <manuq@laptop.org>
-rwxr-xr-xgame.py17
1 files changed, 12 insertions, 5 deletions
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)