Beispiel #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)])
Beispiel #2
0
 def test_insideYBoundary_falseWhenEntityYPosIsNegative(self):
     entityToTest = Entity()
     entityToTest.y = -1
     self.assertFalse(entityToTest.inside_y_boundary())
Beispiel #3
0
 def test_insideXBoundary_falseWhenEntityXPosGreaterThanScreenWidth(self):
     entityToTest = Entity()
     entityToTest.x = WIDTH + 1
     self.assertFalse(entityToTest.inside_x_boundary())
Beispiel #4
0
 def test_insideXBoundary_falseWhenEntityXPosIsNegative(self):
     entityToTest = Entity()
     entityToTest.x = -1
     self.assertFalse(entityToTest.inside_x_boundary())
Beispiel #5
0
 def test_checkCollisions_emptyCollisionsListWhenOtherEntityXPosEqualsSpriteSize(self):
     entityToTest, otherEntity = Entity(), Entity()
     otherEntity.x += SPRITE_SIZE
     entities.append(otherEntity)
     entityToTest.check_collisions()
     self.assertFalse(collisions)
Beispiel #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)])
Beispiel #7
0
 def test_checkCollisions_emptyCollisionsListWhenNoOtherEntities(self):
     entityToTest = Entity()
     entityToTest.check_collisions()
     self.assertFalse(collisions)
Beispiel #8
0
 def test_checkCollisions_entityDoesNotCollideWithSelf(self):
     entityToTest = Entity()
     entities.append(entityToTest)
     entityToTest.check_collisions()
     self.assertFalse(collisions)
Beispiel #9
0
 def test_checkCollisions_collisionsListContainsCollidedEntities(self):
     entityToTest = Entity()
     entityCollidedWith = Entity()
     entities.append(entityCollidedWith)
     entityToTest.check_collisions()
     self.assertListEqual(collisions, [(entityToTest, entityCollidedWith)])
Beispiel #10
0
 def test_insideXBoundary_falseWhenEntityYPosGreaterThanScreenHeight(self):
     entityToTest = Entity()
     entityToTest.y = HEIGHT + 1
     self.assertFalse(entityToTest.inside_y_boundary())