Beispiel #1
0
    def __init__(self):

        self.all_sprites = pygame.sprite.Group()
        self.enemy = pygame.sprite.Group()
        self.crystal = pygame.sprite.Group()
        self.all_platforms = pygame.sprite.Group()

        self.bg = Obj("assets/bg.png", 0, 0, self.all_sprites)

        self.tree1 = Obj("assets/tree1.png", 80, 250, self.all_sprites)
        self.tree2 = Obj("assets/tree2.png", 450, 250, self.all_sprites)
        self.tree3 = Obj("assets/tree1.png", 1060, 250, self.all_sprites)

        self.plat1 = Obj("assets/plat1.png", 50, 550, self.all_sprites, self.all_platforms)
        self.plat2 = Obj("assets/plat3.png", 430, 550, self.all_sprites, self.all_platforms)
        self.plat3 = Obj("assets/plat2.png", 1080, 550, self.all_sprites, self.all_platforms)

        self.crystal1 = Obj("assets/crystal.png", 520, 400, self.all_sprites, self.crystal)
        self.crystal2 = Obj("assets/crystal.png", 870, 400, self.all_sprites, self.crystal)
        self.crystal3 = Obj("assets/crystal.png", 1155, 400, self.all_sprites, self.crystal)

        self.enemy1 = Enemy("assets/enemy0.png", 520, 502, self.all_sprites,  self.enemy)
        self.enemy2 = Enemy("assets/enemy0.png", 800, 502, self.all_sprites, self.enemy)
        self.enemy3 = Enemy("assets/enemy0.png", 1100, 502, self.all_sprites, self.enemy)

        self.player = Hero("assets/idle0.png", 100, 250, self.all_sprites)

        self.hud = Obj("assets/hud.png", 50, 50, self.all_sprites)
Beispiel #2
0
    def __init__(self):

        self.all_sprites = pygame.sprite.Group()#cenario, aqui é o grupo do cenario
        self.all_cube = pygame.sprite.Group()#jogador
        self.all_enemy = pygame.sprite.Group()#inimigo
        self.all_meteor = pygame.sprite.Group()#meteor

        #cenario
        self.bg = Obj("Assets/Background2.png", 0, 0, self.all_sprites)

        #jogador
        self.cube = Cube("Assets/Player2.png", 640, 360, self.all_sprites, self.all_cube)

        random_x = random.randint(100, 1000)

        #inimigo
        self.enemy = Enemy("Assets/enemy2.png", random_x, -750, self.all_sprites, self.all_enemy)
        self.enemy = Enemy("Assets/enemy2.png", 500, -750, self.all_sprites, self.all_enemy)
        self.enemy = Enemy("Assets/enemy2.png", 500, -750, self.all_sprites, self.all_enemy)
        self.enemy = Enemy("Assets/enemy2.png", 500, -750, self.all_sprites, self.all_enemy)
        self.enemy = Enemy("Assets/enemy2.png", 500, -750, self.all_sprites, self.all_enemy)

        #obstaculos
        self.meteor = Meteor("Assets/meteor.png", 100, 1000, self.all_sprites, self.all_meteor)

        #cenario
        self.hud = Obj("Assets/hud_black.png", 10, 10, self.all_sprites)
        self.lifes_1 = Obj("Assets/life_3.png", 107, 14, self.all_sprites)
        self.lifes_2 = Obj("Assets/life_3.png", 116, 14, self.all_sprites)
        self.lifes_3 = Obj("Assets/life_3.png", 125, 14, self.all_sprites)
def test_Enemy_fails_to_construct_with_invalid_healthPoints_type():
    # 3As | Arrange
    # Overwrite testName to be invalid data.
    testHealthPoints = "I wonder if Ayman or Alex will ever read this. Probably not, hi Manish :)"

    # ExpectedOutput is only used to compare the type of the output. Expect int type out.
    expectedOutput = type(testHealthPoints)

    # 3As | Act
    # Attempt to construct character from constructor.
    with assertion.raises(Exception) as exc_info:
        unitUnderTest = EnemyClass.Enemy(testName, testLevel, testHealthPoints,
                                         testIsAlive, mockedEquippedWeapon)

    # 3As | Assert
    # Assert object was not constructed.
    try:
        assert unitUnderTest == None
    except UnboundLocalError:
        assert True

    # Assert that the correct exception was raised.
    assert exc_info.errisinstance(TypeError)
    assert "Enemy healthPoints expected a int. Received: " + str(
        expectedOutput) + " Check the type." in str(exc_info.value)
def test_Enemy_Constructs_With_Valid_Data():
    # 3As | Arrange
    # Nothing, use stock test variables/test setup.

    # 3As | Act
    # Attempt to construct character from constructor.
    unitUnderTest = EnemyClass.Enemy(testName, testLevel, testHealthPoints,
                                     testIsAlive, mockedEquippedWeapon)

    # 3As | Assert
    # Assert that unit Under Test is not null.
    assert unitUnderTest != None

    # Assert that each value was set correctly.
    assert unitUnderTest.name == testName
    assert unitUnderTest.level == testLevel
    assert unitUnderTest.healthPoints == testHealthPoints
    assert unitUnderTest.isAlive == testIsAlive
    assert unitUnderTest.equippedWeapon == mockedEquippedWeapon
    def generateRandomEnemy():

        enemy1 = EnemyClass.Enemy("Skeleton", 30, 500, True,
                                  mock.Mock(spec=WeaponClass.Weapon))

        return enemy1