Example #1
0
 def test_checkCollisions_oneCollisionDetectedWhenMultipleEntitiesPresent(self):
     entityToTest, collidedEntity = Entity(), Entity()
     distantEntity1, distantEntity2 = Entity(), Entity()
     distantEntity1.x, distantEntity1.y = 500, 500
     distantEntity2.x, distantEntity2.y = 800, 800
     entities.extend([collidedEntity, distantEntity1, distantEntity2])
     entityToTest.check_collisions()
     self.assertListEqual(collisions, [(entityToTest, collidedEntity)])
Example #2
0
 def test_insideYBoundary_falseWhenEntityYPosIsNegative(self):
     entityToTest = Entity()
     entityToTest.y = -1
     self.assertFalse(entityToTest.inside_y_boundary())
Example #3
0
 def test_insideXBoundary_falseWhenEntityXPosGreaterThanScreenWidth(self):
     entityToTest = Entity()
     entityToTest.x = WIDTH + 1
     self.assertFalse(entityToTest.inside_x_boundary())
Example #4
0
 def test_insideXBoundary_falseWhenEntityXPosIsNegative(self):
     entityToTest = Entity()
     entityToTest.x = -1
     self.assertFalse(entityToTest.inside_x_boundary())
Example #5
0
 def test_checkCollisions_emptyCollisionsListWhenOtherEntityXPosEqualsSpriteSize(self):
     entityToTest, otherEntity = Entity(), Entity()
     otherEntity.x += SPRITE_SIZE
     entities.append(otherEntity)
     entityToTest.check_collisions()
     self.assertFalse(collisions)
Example #6
0
 def test_checkCollisions_oneCollisionDetectedWhenOtherEntityXPosLessThanSpriteSize(self):
     entityToTest, otherEntity = Entity(), Entity()
     otherEntity.x += SPRITE_SIZE-1
     entities.append(otherEntity)
     entityToTest.check_collisions()
     self.assertListEqual(collisions, [(entityToTest, otherEntity)])
Example #7
0
 def test_checkCollisions_emptyCollisionsListWhenNoOtherEntities(self):
     entityToTest = Entity()
     entityToTest.check_collisions()
     self.assertFalse(collisions)
Example #8
0
 def test_checkCollisions_entityDoesNotCollideWithSelf(self):
     entityToTest = Entity()
     entities.append(entityToTest)
     entityToTest.check_collisions()
     self.assertFalse(collisions)
Example #9
0
 def test_checkCollisions_collisionsListContainsCollidedEntities(self):
     entityToTest = Entity()
     entityCollidedWith = Entity()
     entities.append(entityCollidedWith)
     entityToTest.check_collisions()
     self.assertListEqual(collisions, [(entityToTest, entityCollidedWith)])
Example #10
0
 def test_insideXBoundary_falseWhenEntityYPosGreaterThanScreenHeight(self):
     entityToTest = Entity()
     entityToTest.y = HEIGHT + 1
     self.assertFalse(entityToTest.inside_y_boundary())