X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=koperkapel%2Fgamelib%2Fenemy_roach.py;h=90695b3916f99e2594fd8e1833a251046b9404fa;hb=48f534a2be7df6ebeef92b37b055fdaf0077fed6;hp=2645efa8778cca7dd1939465bfa341d1eea58eb0;hpb=d5a55df04e88672d2275298719a9039ebcf29fea;p=koperkapel.git diff --git a/koperkapel/gamelib/enemy_roach.py b/koperkapel/gamelib/enemy_roach.py index 2645efa..90695b3 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 @@ -10,7 +10,7 @@ from ..roaches import t32_roaches, WorldRoach def get_enemy_roach(level): roach = t32_roaches.assemble(WorldRoach(), color=(255, 0, 0, 255)) - roach.anchor = (0, 0) + roach.anchor = (-16, -16) # this should center them on the tile roach.game_pos = (0, 0) roach.health = 5 roach.level = level @@ -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