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
bullet.level_layer = self._level_layer
self._bullets.add(bullet)
+ def _check_for_bullet_hits(self):
+ for bullet in list(self._bullets):
+ for enemy in list(self._enemies):
+ if enemy.collidepoint(bullet.pos):
+ self._hit_enemy(enemy, bullet.weapon)
+ self._bullets.remove(bullet)
+
def _update_bullet(self, bullet, dt):
bullet.dt += dt
if bullet.dt > 0.1:
bullet.pos = self.calc_offset(
bullet.game_pos[0] * TILE_SIZE + (TILE_SIZE // 2),
bullet.game_pos[1] * TILE_SIZE + (TILE_SIZE // 2))
+ self._check_for_bullet_hits()
more = self._check_held_keys(dt)
if more:
events.extend(more)