コード例 #1
0
ファイル: test_Potato.py プロジェクト: KechuXIV/JumperPY
	def test_PotatoReachCheckpointTrue(self):
		startPosition = Point(10,1)
		finishCord = startPosition
		expectedPosition = Point(startPosition.X*30,startPosition.Y*30)
		keysPressed = []

		self.enviroment.getFinishCords.return_value = finishCord
		self.enviroment.isTile.side_effect = [True]

		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.enviromentExpected.append(call.getStartCords())
		self.enviromentExpected.append(call.getFinishCords())
		self.enviromentExpected.append(call.isTile(Point(10,2)))
		
		self.soundManagerExpected.append(call.getSound().play())

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

		self.assertTrue(self.target.reachCheckpoint)
コード例 #2
0
ファイル: test_Potato.py プロジェクト: KechuXIV/JumperPY
	def test_PotatoShouldDescendIfThereIsNotTileBehind(self):
		startPosition = Point(2,4)
		expectedPosition = Point(60, 128)
		keysPressed = []

		self.enviroment.isTile.side_effect = [False, False]

		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.enviromentExpected.append(call.getStartCords())
		self.enviromentExpected.append(call.getFinishCords())
		self.enviromentExpected.append(call.isTile(Point(2,5)))
		self.enviromentExpected.append(call.isTile(Point(2,5)))

		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)
コード例 #3
0
ファイル: test_Potato.py プロジェクト: KechuXIV/JumperPY
	def test_PotatoDie(self):
		startPosition = Point(1,20)
		startCords = Point(0,1)
		expectedPosition = Point(startCords.X*30,startCords.Y*30)
		keysPressed = []

		self.enviroment.getStartCords.return_value = startCords
		self.enviroment.isTile.side_effect = [False]

		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.enviromentExpected.append(call.getStartCords())
		self.enviromentExpected.append(call.getFinishCords())
		self.enviromentExpected.append(call.isTile(Point(1,21)))
		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)
コード例 #4
0
ファイル: test_Potato.py プロジェクト: NicoKc/JumperPY
    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)
コード例 #5
0
ファイル: test_Potato.py プロジェクト: NicoKc/JumperPY
    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)
コード例 #6
0
ファイル: test_Potato.py プロジェクト: NicoKc/JumperPY
    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)
コード例 #7
0
ファイル: test_Potato.py プロジェクト: NicoKc/JumperPY
    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)
コード例 #8
0
ファイル: test_Potato.py プロジェクト: NicoKc/JumperPY
    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)
コード例 #9
0
ファイル: test_Potato.py プロジェクト: KechuXIV/JumperPY
	def test_MovePotato(self):
		startPosition = Point(1,0)
		keysPressed = []

		self.enviroment.isTile.side_effect = [True]

		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.enviromentExpected.append(call.getStartCords())
		self.enviromentExpected.append(call.getFinishCords())
		self.enviromentExpected.append(call.isTile(Point(1,1)))

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

		self.assertTrue(self.target.isStanding)
コード例 #10
0
ファイル: test_Potato.py プロジェクト: KechuXIV/JumperPY
	def test_MovePotatoJump(self):
		keysPressed = [Key.Space]
		startPosition = Point(1,0)
		expectedPosition = Point(startPosition.X*30, -8)

		self.enviroment.isTile.side_effect = [False, True]

		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.enviromentExpected.append(call.getStartCords())
		self.enviromentExpected.append(call.getFinishCords())

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

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

		self.assertFalse(self.target.isStanding)
コード例 #11
0
ファイル: test_Potato.py プロジェクト: NicoKc/JumperPY
    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)
コード例 #12
0
ファイル: test_Potato.py プロジェクト: KechuXIV/JumperPY
	def test_ShouldNotMoveIfThereIsTileGoingRight(self):
		startPosition = Point(2,4)
		expectedPosition = Point(56, startPosition.Y*30)
		keysPressed = [Key.A]

		self.enviroment.isTile.side_effect = [False, True]

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

		self.enviromentExpected.append(call.getStartCords())
		self.enviromentExpected.append(call.isTile(Point(1,4)))
		self.enviromentExpected.append(call.getFinishCords())
		self.enviromentExpected.append(call.isTile(Point(2,5)))

		self.target.setActualPosition(startPosition)

		self.target.motion(keysPressed)

		self.assertEqual(self.target.ActualPosition, expectedPosition)
コード例 #13
0
ファイル: test_Potato.py プロジェクト: KechuXIV/JumperPY
	def test_MovePotatoLeftInTheEdgeOfTheScreen(self):
		startCord = Point(0,0)
		expectedPosition = Point(600, 0)

		self.enviroment.isTile.side_effect = [False, True, True]

		keysPressed = [Key.A]

		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.updateSprite(expectedPosition.X, expectedPosition.Y))

		self.enviromentExpected.append(call.getStartCords())
		self.enviromentExpected.append(call.isTile(Point(-1,0)))
		self.enviromentExpected.append(call.getFinishCords())
		self.enviromentExpected.append(call.isTile(Point(20,1)))

		self.assertTrue(self.target.isGoingLeft)
		self.assertFalse(self.target.isStanding)
コード例 #14
0
ファイル: test_Potato.py プロジェクト: NicoKc/JumperPY
    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)
コード例 #15
0
ファイル: test_Potato.py プロジェクト: NicoKc/JumperPY
    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)
コード例 #16
0
ファイル: test_Potato.py プロジェクト: KechuXIV/JumperPY
	def test_MovePotatoRight(self):
		keysPressed = [Key.D]
		startPosition = Point(1,0)
		expectedPosition = Point(startPosition.X*30 + 4,
			startPosition.Y)

		self.enviroment.isTile.side_effect = [False, True]

		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.enviromentExpected.append(call.getStartCords())
		self.enviromentExpected.append(call.isTile(Point(2,0)))
		self.enviromentExpected.append(call.getFinishCords())
		self.enviromentExpected.append(call.isTile(Point(1,1)))

		self.target.setActualPosition(startPosition)
		self.target.isGoingRight = True
		self.target.motion(keysPressed)

		self.assertFalse(self.target.isGoingLeft)
		self.assertFalse(self.target.isStanding)