91b404b12bbdea431c1161298edda1a6f9e88d16
[koperkapel.git] / koperkapel / gamelib / enemy_roach.py
1 # Roach utilities
2
3 import random
4
5 from pgzero.clock import each_tick
6 from functools import partial
7
8 from ..roaches import t32_roaches, WorldRoach
9
10
11 def get_enemy_roach(level):
12     roach = t32_roaches.assemble(WorldRoach(), color=(255, 0, 0, 255))
13     roach.anchor = (0, 0)
14     roach.game_pos = (0, 0)
15     roach.health = 5
16     roach.level = level
17     roach.move = partial(move, roach)
18     roach.last_moved = 0
19     each_tick(roach.move)
20     return roach
21
22
23 def move(roach, dt):
24     """Enemy roach move method"""
25     roach.last_moved += dt
26     if roach.last_moved > 0.5:
27         print('Moving')
28         roach.last_moved = 0