Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Cameron <quozl@laptop.org>2013-10-01 00:28:26 (GMT)
committer Laurent Bernabé <laurent.bernabe@gmail.com>2013-10-01 08:23:23 (GMT)
commitfd18b9de2c4e55ca88cfddb1210fa4eef5ec83f4 (patch)
tree91f2060f639e244a3abfd0c4e0921a7d7ade97fb
parent4533d1f2be64ef74d34129cf388919cfa36c8e91 (diff)
lower frame rate, and ensure frame rate is enforced during all phases
-rw-r--r--main_game.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/main_game.py b/main_game.py
index 110ebf3..0e23fd9 100644
--- a/main_game.py
+++ b/main_game.py
@@ -60,7 +60,7 @@ class Game:
return
pygame.init()
self._LEFT_BUTTON = 1
- self._FPS = 40
+ self._FPS = 10
self._MENU_LEVELS_RECTS_Y_GAP = 30
self._MENU_LEVELS_RECTS_WIDTH = 345
self._MENU_LEVELS_RECTS_HEIGHT = 60
@@ -220,6 +220,8 @@ class Game:
pygame.time.set_timer(USEREVENT + 2, 1000)
while True:
+ while Gtk.events_pending():
+ Gtk.main_iteration()
pygame.display.update()
self._screen.fill(self._GAME_BACKGROUND)
paint_result_bar(result_bar, self._screen)
@@ -228,9 +230,6 @@ class Game:
for ball in the_balls:
paint_ball(ball, self._screen)
- while Gtk.events_pending():
- Gtk.main_iteration()
-
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
@@ -253,7 +252,6 @@ class Game:
game_state = GameState.WON
else:
game_state = GameState.LOST
- self._clock.tick(self._FPS)
for ball in the_balls:
ball.move()
balls_collision.manage_colliding_balls(the_balls)
@@ -270,9 +268,6 @@ class Game:
self._RED)
self._screen.blit(end_txt_surface, self._END_TXT_POS)
- while Gtk.events_pending():
- Gtk.main_iteration()
-
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
@@ -282,6 +277,7 @@ class Game:
elif event.type == MOUSEBUTTONUP:
if event.button == self._LEFT_BUTTON:
return
+ self._clock.tick(self._FPS)
def show_menu(self):
"""
@@ -324,3 +320,4 @@ class Game:
self._play_game(
30,
self._levels[selected_level_index])
+ self._clock.tick(self._FPS)