From 6e7a1f34e26ef0fe59eb54435b78166ad2c2a979 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 5 Mar 2016 23:28:50 +0200 Subject: [PATCH] Cleanup stale enemy move things --- koperkapel/gamelib/enemy_roach.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- 2.34.1