From: Neil Date: Sat, 5 Mar 2016 21:28:50 +0000 (+0200) Subject: Cleanup stale enemy move things X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=6e7a1f34e26ef0fe59eb54435b78166ad2c2a979;p=koperkapel.git Cleanup stale enemy move things --- diff --git a/koperkapel/gamelib/enemy_roach.py b/koperkapel/gamelib/enemy_roach.py index 2645efa..2e51ef0 100644 --- a/koperkapel/gamelib/enemy_roach.py +++ b/koperkapel/gamelib/enemy_roach.py @@ -2,7 +2,7 @@ import random -from pgzero.clock import each_tick +from pgzero.clock import each_tick, unschedule from functools import partial from ..roaches import t32_roaches, WorldRoach @@ -24,6 +24,9 @@ def get_enemy_roach(level): def move(roach, dt): """Enemy roach move method""" roach.last_moved += dt + if not roach in roach.level.enemies: + unschedule(roach.move) + return if roach.last_moved > 0.5: if not roach.start_pos: roach.start_pos = roach.game_pos