projects
/
koperkapel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix enemy respawning. Slow rate a bit
[koperkapel.git]
/
koperkapel
/
gamelib
/
enemy_roach.py
diff --git
a/koperkapel/gamelib/enemy_roach.py
b/koperkapel/gamelib/enemy_roach.py
index 95b3e19912eb6312f9718df1a3eccb1c56ab658b..91b404b12bbdea431c1161298edda1a6f9e88d16 100644
(file)
--- a/
koperkapel/gamelib/enemy_roach.py
+++ b/
koperkapel/gamelib/enemy_roach.py
@@
-1,11
+1,28
@@
# Roach utilities
# Roach utilities
+import random
+
+from pgzero.clock import each_tick
+from functools import partial
+
from ..roaches import t32_roaches, WorldRoach
from ..roaches import t32_roaches, WorldRoach
-def get_enemy_roach():
- # red
+def get_enemy_roach(level):
roach = t32_roaches.assemble(WorldRoach(), color=(255, 0, 0, 255))
roach.anchor = (0, 0)
roach.game_pos = (0, 0)
roach = t32_roaches.assemble(WorldRoach(), color=(255, 0, 0, 255))
roach.anchor = (0, 0)
roach.game_pos = (0, 0)
+ roach.health = 5
+ roach.level = level
+ roach.move = partial(move, roach)
+ roach.last_moved = 0
+ each_tick(roach.move)
return roach
return roach
+
+
+def move(roach, dt):
+ """Enemy roach move method"""
+ roach.last_moved += dt
+ if roach.last_moved > 0.5:
+ print('Moving')
+ roach.last_moved = 0