Mercurial > rinkhals
changeset 369:25f7d4824250
Disable timers during move_foxes loop to stop events piling up too much
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Thu, 10 Sep 2009 15:18:39 +0000 |
parents | 14d49a7d8ffc |
children | b3c90e49a6b7 |
files | TODO gamelib/engine.py |
diffstat | 2 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/TODO Thu Sep 10 12:34:57 2009 +0000 +++ b/TODO Thu Sep 10 15:18:39 2009 +0000 @@ -61,6 +61,9 @@ return pygame.event.post(START_DAY) pygame.error: Event queue full """ + - r370 disables timer events while processing the fox movements and + chicken attacks. This should make this bug harder to trigger. + Leaking weakref objects bug (reported by tumbleweed): - this is probably http://pygame.motherhamster.org/bugzilla/show_bug.cgi?id=30
--- a/gamelib/engine.py Thu Sep 10 12:34:57 2009 +0000 +++ b/gamelib/engine.py Thu Sep 10 15:18:39 2009 +0000 @@ -216,9 +216,12 @@ elif e.type is ANIM_ID: self.game.gameboard.run_animations() elif e.type is MOVE_FOX_ID: - # Timer aren't nessecairly ordered, so we make sure - # we don't get a ANIM event until at least cycle after this - pygame.time.set_timer(ANIM_ID, self.cycle_time) + # ensure no timers trigger while we're running + pygame.time.set_timer(ANIM_ID, 0) + pygame.time.set_timer(MOVE_FOX_ID, 0) + # Clear any queued timer events, so we don't full the queue + pygame.event.clear(ANIM_ID) + pygame.event.clear(MOVE_FOX_ID) # Ensure any outstanding animitions get cleaned up self.game.gameboard.run_animations() self.cycle_count += 1 @@ -227,6 +230,9 @@ if self.game.gameboard.move_foxes(): # All foxes are gone/safe, so dawn happens return pygame.event.post(START_DAY) + # Re-enable timers + pygame.time.set_timer(ANIM_ID, self.cycle_time) + pygame.time.set_timer(MOVE_FOX_ID, 4*self.cycle_time) elif e.type is not QUIT: self.game.main_app.event(e)