def destroy(self, position=None): if not position: position = self.position animation = explosionStandartBulletAnimation(self.position, self.rotation) get_main_layer().dispatch_event('add_animation', animation) super(StandartBullet, self).destroy()
def on_animation_end(self): # Global.Layers.removeAnimation(self) try: get_main_layer().dispatch_event('remove_animation', self) self.delete() except Exception as e: print('Exception', e) print(self, self.position)
def fire(self, bullet=None): position = self.firePosition() rotation = self.fireRotation() animatiom_position = self.fireAnimationPosition() animatiom_rotation = self.tank.getGunRotation() bullet = StandartBullet(position, rotation, fired_tank=self.tank) get_main_layer().dispatch_event('add_bullet', bullet) animation = StandartBulletFireAnimation(animatiom_position, animatiom_rotation) get_main_layer().dispatch_event('add_animation', animation)
def checkDamageCollisions(self): main_scene = get_main_layer() for tank in main_scene.tanksLayer.get_children(): tank.cshape = cm.AARectShape(tank.position, tank.width // 2, tank.height // 2) damage_collisions = Global.CollisionManager.objs_colliding(self) if damage_collisions: # for damage_wall in main_scene.objectsLayer.get_children(): # if damage_wall.type == 'destroyable': # if damage_wall in damage_collisions: # damage_wall.damage(self.bullet) for player in main_scene.tanksLayer.get_children(): if player in damage_collisions: dmg = player.damage(self.bullet)
def destroy(self, position=None): main = get_main_layer() main.bulletsLayer.remove(self) CollisionManager.remove_tricky(self)
def get_observation(self): return get_main_layer().get_observation(self.target)