def addGamePlayer(type, clan, position=(100, 100), rotation=0, add_moving_handler=False, id=None, bot=False): tank = TankHelper.getTankByType(int(type)) if id: tank.id = id else: tank.id = Global.getNextId() tank.clan = clan tank.bot = bot tank.position = position # tank.gun_rotation = rotation tank.rotation = rotation #self.sendAllTanksToClients() if add_moving_handler: tank.do(UserTankMovingHandlers()) if bot: tank.do(BotTankMovingHandlers()) # tank.moving_handler = BotTankMovingHandlers(tank) # tank.moving_handler.start() Global.addTankToObjectsAndSprites(tank) return tank.id
def load_map(): for wall in Global.get_map(): wall = LandingObject(wall) wall.id = Global.getNextId() Global.all_walls.append(wall) # if wall.type != 0 and wall.type != 1: # Global.walls.append(wall) set_walls()
def __init__(self, id=0, position=(0, 0), rotation=0, clan=1): super(Building, self).__init__(self.src) if not id: id = Global.getNextId() self.id = id self.position = position self.rotation = rotation self.clan = clan self.healthHelper = HealthSprite() self.updateHealthPosition() self.cshape = cm.AARectShape(self.position, self.width // 2, self.height // 2)
def fire(self): if not self.canFire: return id = Global.getNextId() rotation = self.rotation - 90 animation_rotation = self.rotation parent_id = self.id animation_position = self.getFirePosition(-30, -10) position = self.getFirePosition(-30, -10) self.weapon.fire(id=id, position=position, animation_position=animation_position, animation_rotation=animation_rotation, rotation=rotation, parent_id=parent_id) self.canFire = False Timer(self.bulletFreezTime, self.acceptFire).start()
def create(instance, parent_id, position, rotation=0, last_update_time=time(), id=None, animation_instance=None, animation_position=None, animation_rotation=None, add_moving_handler=None): if not id: id = Global.getNextId() if not animation_position: animation_position = position if not animation_rotation: animation_rotation = rotation bullet = instance() bullet.id = id bullet.parent_id = parent_id bullet.position = position bullet.start_position = position bullet.rotation = rotation bullet.last_update_time = last_update_time bullet.animation_position = animation_position bullet.animation_rotation = animation_rotation addBulletToGame(bullet) if add_moving_handler: bullet.do(BulletMovingHandlers()) if animation_instance: animation = animation_instance() animation.appendAnimationToLayer(animation_position, animation_rotation) return bullet