Enemy movement is something we may eventually do
[koperkapel.git] / koperkapel / gamelib / enemy_roach.py
index e36b1765802c4e953f022cdd50a6984824b7122d..91b404b12bbdea431c1161298edda1a6f9e88d16 100644 (file)
@@ -1,12 +1,28 @@
 # Roach utilities
 
+import random
+
+from pgzero.clock import each_tick
+from functools import partial
+
 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.health = 5
+    roach.level = level
+    roach.move = partial(move, roach)
+    roach.last_moved = 0
+    each_tick(roach.move)
     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