def __init__(self, shooter, game_obj, range=500, damage=20, *args, **kwargs): GameObject.__init__(self, *args, **kwargs) self.range = range self.damage = damage self.shooter = shooter self.game_obj = game_obj self.push_forward(self.max_vel) self.start_loc = self.loc
def get_data(self): d = GameObject.get_data(self) d['shooter_id'] = self.shooter.id return d
def update(self, delta, relative_obj): GameObject.update(self, delta, relative_obj) if self.loc.sub(self.start_loc).magnitude() > self.range: self.game_obj.remove_obj(self)
def __init__(self, game_obj, source): GameObject.__init__(self, source=source) self.game_obj = game_obj
def set_data(self, data): GameObject.set_data(self, data) if 'health' in data: self.health = data['health']
def get_data(self): d = GameObject.get_data(self) d['health'] = self.health return d
def update(self, delta, relative_obj): GameObject.update(self, delta, relative_obj) if self.controls['thrust'] == 1: self.push_forward() if self.controls['turn_right'] == 1: self.turn_right() if self.controls['turn_left'] == 1: self.turn_left() if self.controls['attack'] == 1: self.shoot()
def __init__(self, game_obj, controls=None): GameObject.__init__(self, source=game_obj.image_map['player']) self.image_map = game_obj.image_map self.game_obj = game_obj if controls: self.controls.update(controls)