def checkDamageCollisions(self): for player in Global.getGameTanks(): player.cshape = cm.AARectShape(player.position, player.width // 2, player.height // 2) # for enemy in Global.objects['enemies']: # enemy.cshape = cm.AARectShape( # enemy.position, # enemy.width // 2, # enemy.height // 2 # ) damage_collisions = Global.CollisionManager.objs_colliding(self) if damage_collisions: for damage_wall in Global.getGameWalls(): if damage_wall.type == 'destroyable': if damage_wall in damage_collisions: damage_wall.damage(self.bullet) for player in Global.getGameTanks(): if player in damage_collisions: player.damage(self.bullet) for obj in Global.getGameObjects(): if obj in damage_collisions: obj.damage(self.bullet)
def checkManualCollisionsWidthWalls(object): object_points = object.getPoints() for wall in Global.getGameWalls(): wall_points = wall.getPoints() if Collisions.wallNearObject(object_points, wall_points): if Collisions.intersection(object_points, wall_points): return True
def checkWithWalls(object): try: collisions = Global.CollisionManager.objs_colliding(object) except AttributeError: return False if collisions: for wall in Global.getGameWalls(): if wall in collisions: return True return False
def printDebugInfo(self): bullets = Global.getGameBullets() tanks = Global.getGameTanks() walls = Global.getGameWalls() CM = Global.CollisionManager LayersTanks = Global.Layers.tanks LayersWalls = Global.Layers.walls LayersBullets = Global.Layers.bullets LayersAnimations = Global.Layers.globalPanel print('bullets', len(bullets), 'LayersBullets', len(LayersBullets.children), 'LayersAnimations', len(LayersAnimations.children), 'CollisionManager', len(CM.objs), 'tanks', len(tanks))
def checkDamageCollisionsOLD(self): damage_collisions = Global.CollisionManager.objs_colliding(self) if damage_collisions: for damage_wall in Global.getGameWalls(): if damage_wall in damage_collisions: damage_wall.damage(self.bullet) for player in Global.getGameTanks(): #if parent_id == player.id: continue player_points = player.getPoints() if Collisions.check(player_points, self.bullet.position): player.damage(self.bullet)