Beispiel #1
0
 def test_smash(self):
     Mario = scene.Mario_map(HEIGHT,WIDTH)
     Mario.initialize()
     enemy = small_enemy.enemy_1(HEIGHT-4,WIDTH-12)
     config.ENEMY_COUNT.append(enemy)
     enemy.draw(Mario.map_mario)
     Player = mario_player.Mario(HEIGHT-5,WIDTH-12)
     Player.draw(Mario.map_mario)
     assert Mario.map_mario[HEIGHT-4][WIDTH-12] == "e"
     Mario.smash_enemy(Player.get_y(),Player.get_x())
     assert Mario.map_mario[HEIGHT-4][WIDTH-12] == "."
Beispiel #2
0
 def test_detect(self):
     Mario = scene.Mario_map(HEIGHT,WIDTH)
     Mario.initialize()
     enemy = small_enemy.enemy_1(HEIGHT-4,WIDTH-12)
     config.ENEMY_COUNT.append(enemy)
     enemy.draw(Mario.map_mario)
     assert enemy.follow_coefficient == -1
     Mario.map_mario[HEIGHT-4][WIDTH-11] = "#"
     assert Mario.map_mario[HEIGHT-4][WIDTH-11] == "#"
     enemy.detect_collision(Mario.map_mario)
     assert enemy.follow_coefficient == 1
Beispiel #3
0
 def test_follow(self):
     enemy = small_enemy.enemy_1(HEIGHT-4,WIDTH-12)
     Mario = scene.Mario_map(HEIGHT,WIDTH)
     Mario.initialize()
     enemy.draw(Mario.map_mario) 
     Player = mario_player.Mario(HEIGHT-4,WIDTH-13)
     Player.draw(Mario.map_mario)
     assert enemy.follow(Player.get_y(),enemy.y_original) == -1
     Player2 = mario_player.Mario(HEIGHT-4,WIDTH-11)
     Player2.draw(Mario.map_mario)
     assert enemy.follow(Player2.get_y(),enemy.y_original) == 1
Beispiel #4
0
def init_game(height, width, level):

    config.mario = scene.Mario_map(height, width)

    config.mario.initialize()
    config.enemy = []

    config.coin = coins.Coins()
    config.cake = cake.Cakes()
    config.pistol = pistol.Pistol()
    config.flagger = flag_1.Flag(config.mario.map_mario)

    if level == 1:
        counter = 3
    elif level == 2:
        counter = 4

    #initialize enemies
    for i in range(0, counter - 2):
        for i in config.mario.boundary:
            enemy_original_y = i + randint(int(width / 2), width - 15)
            enemy_original_x = height - 4
            config.enemy.append(
                small_enemy.enemy_1(enemy_original_x, enemy_original_y))
        stable_set = ["#", "&"]

    #initialize clouds
    for i in config.mario.boundary:
        n = randint(counter, counter + 2)
        for count in range(0, n):
            cloud = clouds.Clouds(config.mario.map_mario)
            cloud_x, cloud_y = randint(30, 140) + i, randint(3, 5)
            cloud.update(n, cloud_y, cloud_x)
            config.clouds.append(cloud)

    #initialize pillars
    for i in config.mario.boundary:
        for count in range(0, counter):
            pole = poles.Poles(config.mario.map_mario)
            pole_x, pole_y = randint(int(width / 2),
                                     width - 15) + i, height - 4
            pole.draw(pole_x, pole_y)
            config.poles.append(pole)

    #initialize stairs
    for count in range(0, 3):
        config.ending = ending.End(config.mario.map_mario)
        stair_x, stair_y = width * 6 + 20 + count * 21, height - 10
        config.ending.draw_left(stair_x, stair_y, height, width)
        stair_x, stair_y = width * 6 + 31 + count * 21, height - 10
        config.ending.draw_right(stair_x, stair_y, height, width)
        config.stair_coordinates.append([stair_x, stair_y])

    #initialize coins
    for j in range(0, 4):
        for i in range(0, 6):
            k = randint(height - 14, height - 8)
            a = randint(int(width / 12), width - 24)
            b = a + 12
            config.coin.set_position(k, a, randint(0, 13),
                                     config.mario.boundary[i])
            config.coin.set_position(k, a, randint(0, 13),
                                     config.mario.boundary[i])
            config.mario.make_wall(k, a, b, config.char, i)
            config.mario.make_wall(k - 1, a, b, config.char, i)
            if i % 3 == 0:
                cake_y, cake_x = k, a + randint(1,
                                                11) + config.mario.boundary[i]
                config.cake.set_position(cake_y, cake_x)
            if i % 3 == 1:
                pistol_y, pistol_x = k, a + randint(
                    1, 11) + config.mario.boundary[i]
                config.pistol.set_position(pistol_y, pistol_x)

    #initialize variables
    config.x_flag = width * 6 + int(width / 2) + 30
    config.y_flag = height - 14
    config.flagger.draw_2(config.y_flag, config.x_flag)
    config.distance = 0
    config.score = 0
    config.index = 0
    config.counter = 0
    config.counter_back = 0
    config.start_x = 0
    os.system('clear')
    print("score- " + str(config.score) + " " + "distance- " +
          str(config.distance))
    config.player = mario_player.Mario(int(height - 4), 0)
    config.player.draw(config.mario.map_mario)
    for items in config.enemy:
        items.draw(config.mario.map_mario)
        config.enemy_count.append(1)
    config.mario.print_map(int(width), int(height), config.start_x)
    config.final_height = height - 4
    config.limit = 0
    config.flag = 1
    config.follow_coefficient = -1
    config.game_over = False
    config.big_mario = False
    os.system('aplay -qN ./sound/theme.wav &')
Beispiel #5
0
def init_game(height, width, level):
    """gaurav"""
    config.mario = scene.Mario_map(height, width)

    config.mario.initialize()
    config.ENEMY = []

    config.coin = coins.Coins()
    config.cake = cake.Cakes()
    config.pistol = pistol.Pistol()
    config.flagger = flag_1.Flag(config.mario.map_mario)

    if level == 1:
        counter = 3
    elif level == 2:
        counter = 4

    # initialize enemies
    for j in range(0, counter - 2):
        for i in config.mario.boundary:
            enemy_original_y = i + randint(int(width / 2), width - 15)
            enemy_original_x = height - 4
            config.ENEMY.append(
                small_enemy.enemy_1(enemy_original_x, enemy_original_y))
    for i in config.mario.boundary:
        number = randint(counter, counter + 2)
        for count in range(0, number):
            cloud = clouds.Clouds(config.mario.map_mario)
            cloud_x, cloud_y = randint(30, 140) + i, randint(3, 5)
            cloud.update(number, cloud_y, cloud_x)
            config.CLOUDS.append(cloud)

    # initialize pillars
    for i in config.mario.boundary:
        for count in range(0, counter):
            pole = poles.Poles(config.mario.map_mario)
            pole_x, pole_y = randint(int(width / 2),
                                     width - 15) + i, height - 4
            pole.draw(pole_x, pole_y)
            config.POLES.append(pole)

    # initialize stairs
    for count in range(0, 3):
        config.ending = ending.End(config.mario.map_mario)
        stair_x, stair_y = width * 6 + 20 + count * 21, height - 10
        config.ending.draw_left(stair_x, stair_y, height, width)
        stair_x, stair_y = width * 6 + 31 + count * 21, height - 10
        config.ending.draw_right(stair_x, stair_y, height, width)
        config.STAIR_COORDINATES.append([stair_x, stair_y])

    # initialize coins
    for j in range(0, 4):
        for i in range(0, 6):
            j = j
            temp = randint(height - 14, height - 8)
            air = randint(int(width / 12), width - 24)
            boom = air + 12
            config.coin.set_position(temp, air, randint(0, 13),
                                     config.mario.boundary[i])
            config.coin.set_position(temp, air, randint(0, 13),
                                     config.mario.boundary[i])
            config.mario.make_wall(temp, air, boom, config.CHAR, i)
            config.mario.make_wall(temp - 1, air, boom, config.CHAR, i)
            if i % 3 == 0:
                cake_y, cake_x = temp, air + \
                    randint(1, 11)+config.mario.boundary[i]
                config.cake.set_position(cake_y, cake_x)
            if i % 3 == 1:
                pistol_y, pistol_x = temp, air + \
                    randint(1, 11)+config.mario.boundary[i]
                config.pistol.set_position(pistol_y, pistol_x)

    # initialize variables
    config.X_FLAG = width * 6 + int(width / 2) + 30
    config.Y_FLAG = height - 14
    config.flagger.draw_2(config.Y_FLAG, config.X_FLAG)
    config.DISTANCE = 0
    config.SCORE = 0
    config.INDEX = 0
    config.COUNTER = 0
    config.COUNTER_BACK = 0
    config.START_X = 0
    os.system('clear')
    print("score- " + str(config.SCORE) + " " + "distance- " +
          str(config.DISTANCE))
    config.player = mario_player.Mario(int(height - 4), 0)
    config.player.draw(config.mario.map_mario)
    for items in config.ENEMY:
        items.draw(config.mario.map_mario)
        config.ENEMY_COUNT.append(1)
    config.mario.print_map(int(width), int(height), config.START_X)
    config.FINAL_HEIGHT = height - 4
    config.LIMIT = 0
    config.FLAG = 1
    config.follow_coefficient = -1
    config.GAME_OVER = False
    config.BIG_MARIO = False
    os.system('aplay -qN ./sound/theme.wav &')