def _testEnemyBulletCollision( self ): """ Tests to see if any of the enemy bullets hit the player. This modifies Player.hit to True if there is a hit detected """ for bullet in self._bulletList: if bullet.destroyed: self._bulletList.remove( self, bullet ) elif bullet.collidesWith( self, player ): player.hit = True bullet.hit = True break # if the player is hit once, no point in checking others
def _testPlayerBulletCollision( self, entity ): """ Tests if the player's bullets have collided with any enemies. This also applys the hits to enemies as needed. Parameters: Enemy->entity Returns: None """ for bullet in self._playerBulletList: if bullet.destroyed: self._playerBulletList.remove( bullet ) elif bullet.collidesWith( entity ): entity.applyHit( bullet ) self._playerBulletList.remove( bullet ) distance = math.sqrt( math.pow( entity.xpos + bullet.xpos, 2) - \ math.pow( entity.ypos + bullet.xpos, 2 )) if distance < 100: entity.heat += ( 100 - distance ) / 10