示例#1
0
    def test_MovePotatoRightInTheEdgeOfTheScreen(self):
        startCord = Point(20, 0)
        expectedPosition = Point(0, 0)
        collision = {
            Position.BEHIND: True,
            Position.RIGHT: False,
            Position.CHECKPOINT: False
        }
        keysPressed = [Key.D]

        self.collisionManager.getCollisions.return_value = collision

        self.target.setActualPosition(startCord)
        self.target.motion(keysPressed)

        self.spriteManagerExpected.append(
            call.updateSpriteImage(
                os.path.join('JumperPY', 'bin', 'Resources',
                             'potatoWalking.png')))
        self.spriteManagerExpected.append(call.flipSpriteImage())
        self.spriteManagerExpected.append(
            call.updateSprite(expectedPosition.X, expectedPosition.Y))
        self.collisionManagerExpected.append(call.getCollisions())

        self.assertFalse(self.target.isGoingLeft)
        self.assertFalse(self.target.isStanding)
示例#2
0
    def test_ShouldNotMoveIfThereIsTileGoingRight(self):
        startPosition = Point(2, 4)
        expectedPosition = Point(startPosition.X * 30, startPosition.Y * 30)
        collision = {
            Position.BEHIND: True,
            Position.RIGHT: True,
            Position.CHECKPOINT: False
        }
        keysPressed = [Key.D]

        self.collisionManager.getCollisions.return_value = collision

        self.spriteManagerExpected.append(
            call.updateSpriteImage(
                os.path.join('JumperPY', 'bin', 'Resources',
                             'potatoWalking.png')))
        self.spriteManagerExpected.append(call.flipSpriteImage())
        self.spriteManagerExpected.append(
            call.updateSprite(expectedPosition.X, expectedPosition.Y))
        self.collisionManagerExpected.append(call.getCollisions())

        self.target.setActualPosition(startPosition)
        self.target.motion(keysPressed)

        self.assertEqual(self.target.ActualPosition, expectedPosition)
示例#3
0
    def test_PotatoShouldDescendIfThereIsNotTileBehind(self):
        startPosition = Point(2, 4)
        expectedPosition = Point(60, 128)
        collision = {Position.BEHIND: False, Position.CHECKPOINT: False}
        keysPressed = []

        self.collisionManager.getCollisions.return_value = collision

        self.spriteManagerExpected.append(
            call.updateSpriteImage(
                os.path.join('JumperPY', 'bin', 'Resources',
                             'potatoJumping.png')))
        self.spriteManagerExpected.append(call.flipSpriteImage())
        self.spriteManagerExpected.append(
            call.updateSprite(expectedPosition.X, expectedPosition.Y))
        self.collisionManagerExpected.append(call.getCollisions())
        self.soundManagerExpected.append(call.getSound().play())

        self.target.setActualPosition(startPosition)
        self.target.motion(keysPressed)

        self.assertEqual(self.target.ActualPosition, expectedPosition)
        self.assertFalse(self.target.isStanding)
        self.assertTrue(self.target.isGoingDown)
        self.assertTrue(self.target.isJumping)
示例#4
0
    def test_PotatoDie(self):
        startPosition = Point(1, 20)
        startCords = Point(0, 1)
        expectedPosition = Point(startCords.X * 30, startCords.Y * 30)
        collision = {Position.BEHIND: False, Position.CHECKPOINT: False}
        keysPressed = []

        self.enviroment.getStartCords.return_value = startCords
        self.collisionManager.getCollisions.return_value = collision

        self.spriteManagerExpected.append(
            call.updateSpriteImage(
                os.path.join('JumperPY', 'bin', 'Resources',
                             'potatoStanding.png')))
        self.spriteManagerExpected.append(call.flipSpriteImage())
        self.spriteManagerExpected.append(
            call.updateSprite(expectedPosition.X, expectedPosition.Y))
        self.collisionManagerExpected.append(call.getCollisions())
        self.enviromentExpected.append(call.getStartCords())

        self.soundManagerExpected.append(call.getSound().play())

        self.target.setActualPosition(startPosition)
        self.target.isJumping = True
        self.target.isGoingDown = True
        self.target.motion(keysPressed)

        self.assertEqual(expectedPosition, self.target.ActualPosition)
示例#5
0
    def test_MovePotatoLeft(self):
        startPosition = Point(1, 0)
        expectedPosition = Point(startPosition.X * 30 - 4, startPosition.Y)
        collision = {
            Position.BEHIND: True,
            Position.LEFT: False,
            Position.CHECKPOINT: False
        }
        keysPressed = [Key.A]

        self.collisionManager.getCollisions.return_value = collision

        self.spriteManagerExpected.append(
            call.updateSpriteImage(
                os.path.join('JumperPY', 'bin', 'Resources',
                             'potatoWalking.png')))
        self.spriteManagerExpected.append(
            call.updateSprite(expectedPosition.X, expectedPosition.Y))
        self.collisionManagerExpected.append(call.getCollisions())

        self.target.setActualPosition(startPosition)
        self.target.isGoingLeft = False
        self.target.motion(keysPressed)

        self.assertTrue(self.target.isGoingLeft)
        self.assertFalse(self.target.isStanding)
示例#6
0
    def test_MovePotato(self):
        startPosition = Point(1, 0)
        keysPressed = []
        collision = {Position.BEHIND: True, Position.CHECKPOINT: False}

        self.collisionManager.getCollisions.return_value = collision

        self.spriteManagerExpected.append(
            call.updateSpriteImage(
                os.path.join('JumperPY', 'bin', 'Resources',
                             'potatoStanding.png')))
        self.spriteManagerExpected.append(call.flipSpriteImage())
        self.spriteManagerExpected.append(
            call.updateSprite(startPosition.X * 30, startPosition.Y))
        self.collisionManagerExpected.append(call.getCollisions())

        self.target.setActualPosition(startPosition)
        self.target.motion(keysPressed)

        self.assertTrue(self.target.isStanding)
示例#7
0
    def test_MovePotatoJump(self):
        keysPressed = [Key.Space]
        startPosition = Point(1, 0)
        expectedPosition = Point(startPosition.X * 30, -8)
        collision = {Position.CHECKPOINT: False}

        self.collisionManager.getCollisions.return_value = collision

        self.spriteManagerExpected.append(
            call.updateSpriteImage(
                os.path.join('JumperPY', 'bin', 'Resources',
                             'potatoJumping.png')))
        self.spriteManagerExpected.append(call.flipSpriteImage())
        self.spriteManagerExpected.append(
            call.updateSprite(expectedPosition.X, expectedPosition.Y))
        self.soundManagerExpected.append(call.getSound().play())
        self.collisionManagerExpected.append(call.getCollisions())

        self.target.setActualPosition(startPosition)
        self.target.motion(keysPressed)

        self.assertFalse(self.target.isStanding)
示例#8
0
    def test_PotatoReachCheckpointFalse(self):
        startPosition = Point(2, 5)
        expectedPosition = Point(startPosition.X * 30, startPosition.Y * 30)
        collision = {Position.BEHIND: True, Position.CHECKPOINT: False}
        keysPressed = []

        self.collisionManager.getCollisions.return_value = collision

        self.spriteManagerExpected.append(
            call.updateSpriteImage(
                os.path.join('JumperPY', 'bin', 'Resources',
                             'potatoStanding.png')))
        self.spriteManagerExpected.append(call.flipSpriteImage())
        self.spriteManagerExpected.append(
            call.updateSprite(expectedPosition.X, expectedPosition.Y))
        self.collisionManagerExpected.append(call.getCollisions())

        self.target.setActualPosition(startPosition)

        result = self.target.motion(keysPressed)

        self.assertFalse(result)
        self.assertFalse(self.target.reachCheckpoint)