def update(self): self.update_AI() new_pos = self.rect.center dir_mod = 0 # if self.command is not 'Wait': # new_angle = self.new_angle() if self.command is 'TurnLeft': dir_mod = 1 elif self.command is 'TurnRight': dir_mod = -1 elif self.command is 'Forward': new_pos = self.new_pos() if self.command is 'Kick': self.kicking = 1 else: self.kicking = 0 # new_orientation = 0 new_orientation = self.orientation + dir_mod * self.speed_rotation if new_orientation < -180: new_orientation = 180 elif new_orientation > 180: new_orientation = -180 old_center = (new_pos[0], new_pos[1]) self.image = pygw.rotate(self.or_image, new_orientation) self.rect = self.image.get_rect() self.rect.center = old_center self.orientation = new_orientation self.angle = self.agent_to_abs(self.orientation) self.pos = new_pos
def __init__(self, posxy, playerid, angle, WMSubscriber): MovingObject.MovingObject.__init__(self) self.player_icon(playerid) self.load_image() self.rect.center = (posxy[0], posxy[1]) self.orientation = self.abs_to_agent(angle) self.or_image = self.image self.image = pygw.rotate(self.or_image, self.orientation) self.player_id = playerid self.pos = posxy self.angle = angle # ANGLE = [0 to 360 Clockwise] self.WorldModel = WMSubscriber self.AI = AIModule(self.player_id, self.WorldModel) self.speed_rotation = 0.5 self.speed_forward = 1.5 self.cnt = 30 self.command = 'Wait'