def update(self): Child.update(self) self.regen() ### Follow Player ### if self.state == self.states.FOLLOW: # get player location p_x, p_y = self.player.rect.centerx, self.player.rect.centery # check if bot in range rad_x = range(p_x - self.radius_x, p_x + self.radius_x) rad_y = range(p_y - self.radius_y, p_y + self.radius_y) rect_x, rect_y = self.rect.centerx, self.rect.centery # if not next to player, move bot to player self.reset_keys() if rect_x not in rad_x: if rect_x < rad_x[0]: self.move_dir(self.RIGHT) if rect_x > rad_x[0]: self.move_dir(self.LEFT) self.h_decel = False self.update_movement(self.keys) else: self.h_decel = True if rect_y not in rad_y: if rect_y < rad_y[0]: self.move_dir(self.DOWN) if rect_y > rad_y[0]: self.move_dir(self.UP) self.v_decel = False self.update_movement(self.keys) else: self.v_decel = True ### Attack Enemies ### elif self.state == self.states.ATTACK: pass ### Defend Player ### elif self.state == self.states.DEFEND: pass ### Collect Scales ### elif self.state == self.states.COLLECT: pass
def update(self): Child.update(self) self.regen()