Exemplo n.º 1
0
    def create_coins(self):
        # Dependencies: Bridges, walls, holes

        mid = int((self.bridges[0].min_x + self.bridges[0].max_x) / 2)
        self.coins.append(
            Obj(mid, self.bridges[0].min_y - 1, mid, self.bridges[0].min_y - 1,
                config.COIN, self.map_array, self.object_array))
        mid = int((self.bridges[1].min_x + self.bridges[1].max_x) / 2)

        for x_pos, y_pos in zip(
                range(mid - 4, mid + 2, 2),
                range(self.bridges[1].min_y - 1, self.bridges[1].min_y - 4,
                      -1)):
            self.coins.append(
                Obj(x_pos, y_pos, x_pos, y_pos, config.COIN, self.map_array,
                    self.object_array))
        for x_pos, y_pos in zip(
                range(mid + 2, mid + 8, 2),
                range(self.bridges[1].min_y - 2, self.bridges[1].min_y, 1)):
            self.coins.append(
                Obj(x_pos, y_pos, x_pos, y_pos, config.COIN, self.map_array,
                    self.object_array))

        self.coins.append(
            Obj(self.sub_holes[0].max_x, self.sub_holes[0].max_y,
                self.sub_holes[0].max_x, self.sub_holes[0].max_y, config.TIME,
                self.map_array, self.object_array))
        for x_pos in range(self.holes[0].max_x + 5, self.bridges[2].min_x - 5,
                           3):
            self.coins.append(
                Obj(x_pos, self.up_wall.min_y - 1, x_pos,
                    self.up_wall.min_y - 1, config.COIN, self.map_array,
                    self.object_array))
Exemplo n.º 2
0
def nextd(message, bot, group):
    b = Day()
    f = open('Baso-0{}.txt'.format(group),
             'r',
             encoding='utf8',
             errors='ignore')
    today = datetime.today().weekday() + 1
    if today == 7:
        today = 0
    pos = 0
    if today == 0:
        for line in f:
            pos += len(line)
            if line == 'Понедельник:\n':
                break
    elif today == 1:
        for line in f:
            pos += len(line)
            if line == 'Вторник:\n':
                break
    elif today == 2:
        for line in f:
            pos += len(line)
            if line == 'Среда:\n':
                break
    elif today == 3:
        for line in f:
            pos += len(line)
            if line == 'Четверг:\n':
                break
    elif today == 4:
        for line in f:
            pos += len(line)
            if line == 'Пятница:\n':
                break
    elif today == 5:
        for line in f:
            pos += len(line)
            if line == 'Суббота:\n':
                break
    elif today == 6:
        bot.send_message(message.chat.id, 'Завтра воскресенье, пар нет')
        return
    k = 0
    for line in f:
        if k == 12:
            break
        else:
            k += 1
        if today == 0:
            b.objs.append(Obj(line, weeknum() + 1))
        else:
            b.objs.append(Obj(line, weeknum()))
    if today == 0:
        buf = 'Группа - 0{} '.format(group) + b.show(weeknum() + 1, today)
        bot.send_message(message.chat.id, buf)
    else:
        buf = 'Группа - 0{} '.format(group) + b.show(weeknum(), today)
        bot.send_message(message.chat.id, buf)
    f.close()
Exemplo n.º 3
0
    def create_walls(self):
        # Dependencies: None

        self.down_wall = Obj(self.length, self.rows, 1,
                             int((9 * self.rows) / 10), config.DOWN_WALL,
                             self.map_array, self.object_array)
        self.up_wall = Obj(self.length, self.down_wall.min_y - 1, 1,
                           self.down_wall.min_y - 1, config.UP_WALL,
                           self.map_array, self.object_array)
Exemplo n.º 4
0
    def create_lake_fishes(self):
        # Dependencies: walls

        min_x = int(8 * self.columns / 3)
        max_x = int(11 * self.columns / 3)
        self.lake = Obj(max_x, self.down_wall.max_y - 1, min_x,
                        self.up_wall.max_y, config.WATER, self.map_array,
                        self.object_array)
        rand_x = randrange(self.lake.min_x + 2, self.lake.max_x - 2)
        rand_y = self.lake.min_y + randrange(1, 4)
        self.fishes.append(
            Obj(rand_x, rand_y, rand_x, rand_y, config.FISH, self.map_array,
                self.object_array))
        rand_x = randrange(self.lake.min_x + 2, self.lake.max_x - 2)
        rand_y = self.lake.min_y + randrange(1, 4)
        self.fishes.append(
            Obj(rand_x, rand_y, rand_x, rand_y, config.FISH, self.map_array,
                self.object_array))
Exemplo n.º 5
0
    def create_holes(self):
        # Dependencies: walls, bridges

        rand_x = randrange(int(self.columns / 3), int((2 * self.columns) / 3))
        self.holes.append(
            Obj(rand_x + 5, self.down_wall.max_y - 2, rand_x,
                self.up_wall.min_y, ' ', self.map_array, self.object_array))
        self.sub_holes.append(
            Obj(self.holes[0].max_x + 10, self.holes[0].max_y,
                self.holes[0].min_x, self.up_wall.min_y + 2, ' ',
                self.map_array, self.object_array))
        rand_x = randrange(
            int((4 * self.columns) / 3) + 4,
            int(5 * self.columns / 3) - 4)
        self.holes.append(
            Obj(rand_x + 4, self.rows, rand_x - 4, self.up_wall.min_y, ' ',
                self.map_array, self.object_array))
        self.holes.append(
            Obj(self.bridges[5].max_x + 24, self.rows,
                self.bridges[5].max_x + 1, self.up_wall.min_y, ' ',
                self.map_array, self.object_array))
Exemplo n.º 6
0
    def create_bridges(self):
        # Dependencies: walls

        self.bridges.append(
            Obj(20, self.up_wall.min_y - 5, 14, self.up_wall.min_y - 7,
                config.BRIDGE, self.map_array, self.object_array))
        self.bridges.append(
            Obj(40, self.up_wall.min_y - 5, 25, self.up_wall.min_y - 7,
                config.BRIDGE, self.map_array, self.object_array))
        self.bridges.append(
            Obj(self.columns - 4, self.up_wall.min_y - 1, self.columns - 10,
                self.up_wall.min_y - 7, config.BRIDGE, self.map_array,
                self.object_array))

        rand_x = randrange(self.columns + 5, int(4 * self.columns / 3) - 5)
        self.bridges.append(
            Obj(5 + rand_x, self.up_wall.min_y - 5, rand_x - 5,
                self.up_wall.min_y - 8, config.BRIDGE, self.map_array,
                self.object_array))

        rand_x = randrange(int(5 * self.columns / 3) + 1, 2 * self.columns - 2)
        self.bridges.append(
            Obj(rand_x + 1, self.up_wall.min_y - 6, rand_x - 1,
                self.up_wall.min_y - 8, config.BRIDGE, self.map_array,
                self.object_array))

        rand_x = randrange(2 * self.columns + 6,
                           int((7 * self.columns) / 3) - 6)
        cross_bridge_list = [[' ' for _ in range(0, 15)] for _ in range(0, 15)]
        for x_pos in range(0, 15):
            for y_pos in range(15 - x_pos, 15):
                cross_bridge_list[x_pos][y_pos] = config.BRIDGE
        self.bridges.append(
            IrregularObjects(
                {
                    'max_x': rand_x + 6,
                    'max_y': self.up_wall.min_y - 1,
                    'min_x': rand_x - 6,
                    'min_y': self.up_wall.min_y - 14
                }, cross_bridge_list, self.map_array, self.object_array))
Exemplo n.º 7
0
    def setModel(self, text):
        switch = {
            'Box': Box,
            'UVSphere': UVSphere,
            'UVMobius': UVMobius,
            'UVTorus': UVTorus,
            'UVKleinBottle': UVKlein,
        }

        text = str(text)

        if text in switch.keys():
            self.render_obj = switch[text]()
        else:
            self.render_obj = Obj(open(text).read())
Exemplo n.º 8
0
def run():
    """
    Starts the game
    :return:
    """
    start_screen()
    # Initiate the screen
    Obj(c.COLUMNS, c.ROWS, 1, 3, ' ')
    up_wall, _ = create_level1_map()

    c.PLAYER_OBJ.append(
        Player(
            {
                'max_x': 4,
                'max_y': up_wall.min_y - 1,
                'min_x': 3,
                'min_y': up_wall.min_y - 2
            }, c.PLAYER))

    # Create CHECKPOINTS
    c.CHECKPOINTS.append((c.PLAYER_OBJ[0].min_x, c.PLAYER_OBJ[0].max_y))
    c.CHECKPOINTS.append((c.COLUMNS, up_wall.min_y - 1))
    c.CHECKPOINTS.append((c.HOLES_LIST[1].max_x + 4, up_wall.min_y - 1))
    c.CHECKPOINTS.append((c.HOLES_LIST[2].max_x + 4, up_wall.min_y - 1))
    c.CHECKPOINTS.append((c.LAKES[0].max_x + 1, up_wall.min_y - 1))
    c.CONTROL_MUSIC[0].play_music_for_action('Player at start')

    make_updates()
    inp_thread = Thread(target=get_input)
    inp_thread.daemon = True
    inp_thread.start()
    time_thread = Thread(target=decrease_time)
    time_thread.daemon = True
    time_thread.start()

    while True:
        try:
            if c.stop.is_set() or c.timeout.is_set():
                break
            sleep(0.1)
            make_updates()

        except KeyboardInterrupt:
            break

    exit_game()
Exemplo n.º 9
0
    def create_moving_bridges(self):
        # Dependencies: walls, lake

        min_x = int((11 * self.columns) / 3) + 7
        length = 15
        max_x = int((9 * self.columns) / 2)

        # Create Knifes
        self.thrones.append(
            Obj(max_x, self.up_wall.max_y + 1, min_x, self.up_wall.max_y,
                config.THRONES, self.map_array, self.object_array))

        min_y = config.TOP + 5
        max_y = self.lake.min_y - 5
        for x_pos in range(min_x, max_x, 25):
            rand_y = randrange(min_y, max_y + 1)
            self.moving_bridges.append(
                MovingBridges(x_pos + length, rand_y, x_pos, rand_y,
                              config.MOVING_BRIDGES, config.TOP + 5,
                              self.lake.min_y - 5, self))
Exemplo n.º 10
0
def run():
    """
    Starts the game
    :return:
    """
    start_screen()
    # Initiate the screen
    Obj(c.COLUMNS, c.ROWS, 1, 3, ' ')
    up_wall, _ = create_level1_map()
    c.player.append(
        Players(4, up_wall.min_y - 1, 3, up_wall.min_y - 2, c.PLAYER))

    # Create checkpoints
    c.checkpoints.append((c.player[0].min_x, c.player[0].max_y))
    c.checkpoints.append((c.COLUMNS, up_wall.min_y - 1))
    c.checkpoints.append((c.holes_list[1].max_x + 4, up_wall.min_y - 1))
    c.checkpoints.append((c.holes_list[2].max_x + 4, up_wall.min_y - 1))
    c.checkpoints.append((c.lakes[0].max_x + 1, up_wall.min_y - 1))
    c.control_music[0].play_music_for_action('Player at start')

    make_updates()
    inp_thread = Thread(target=get_input)
    inp_thread.daemon = True
    inp_thread.start()
    time_thread = Thread(target=decrease_time)
    time_thread.daemon = True
    time_thread.start()

    while True:
        try:
            if c.stop.is_set() or c.timeout.is_set():
                break
            sleep(0.1)
            make_updates()

        except KeyboardInterrupt:
            break

    exit_game()
Exemplo n.º 11
0
def todayr(message, bot=None, group=1, dayweek=-1):
    b = Day()
    f = open('Baso-0{}.txt'.format(group),
             'r',
             encoding='utf8',
             errors='ignore')
    if dayweek == -1:
        today = datetime.today().weekday()
    else:
        today = dayweek
    pos = 0
    if today == 0:
        for line in f:
            pos += len(line)
            if line == 'Понедельник:\n':
                break
    elif today == 1:
        for line in f:
            pos += len(line)
            if line == 'Вторник:\n':
                break
    elif today == 2:
        for line in f:
            pos += len(line)
            if line == 'Среда:\n':
                break
    elif today == 3:
        for line in f:
            pos += len(line)
            if line == 'Четверг:\n':
                break
    elif today == 4:
        for line in f:
            pos += len(line)
            if line == 'Пятница:\n':
                break
    elif today == 5:
        for line in f:
            pos += len(line)
            if line == 'Суббота:\n':
                break
    elif today == 6:
        if bot is not None:
            bot.send_message(message.chat.id, 'Сегодня воскресенье, пар нет')
        else:
            return 'Сегодня воскресенье, пар нет'
        return
    k = 0
    for line in f:
        if k == 12:
            break
        else:
            k += 1
        b.objs.append(Obj(line, weeknum()))
    if bot is not None:
        buf = 'Группа - 0{} '.format(group) + b.show(weeknum(), today)
        bot.send_message(message.chat.id, buf)
    else:
        buf = b.show(weeknum(), today)
        if buf == 'Сегодня пар нет':
            return 'Группа - 0{} '.format(group) + getweekday(
                today) + ' ' + str(weeknum()) + ' неделя\n' + buf + 2 * '\n'
        else:
            return 'Группа - 0{} '.format(group) + buf + '\n'
    del b
    f.close()
Exemplo n.º 12
0
def create_level1_map():
    """
    Initialises level 1 map of game
    :return:
    """
    # Create the ground for the player
    down_wall = Obj(c.MAP_LENGTH, c.ROWS, 1, int((9 * c.ROWS) / 10),
                    c.DOWN_WALL)
    up_wall = Obj(c.MAP_LENGTH, down_wall.min_y - 1, 1, down_wall.min_y - 1,
                  c.UP_WALL)

    # Create bridges(some at random place and some at predefined place)
    c.bridge_list.append(
        Obj(20, up_wall.min_y - 5, 14, up_wall.min_y - 7, c.BRIDGE))
    c.bridge_list.append(
        Obj(40, up_wall.min_y - 5, 25, up_wall.min_y - 7, c.BRIDGE))
    c.bridge_list.append(
        Obj(c.COLUMNS - 4, up_wall.min_y - 1, c.COLUMNS - 10,
            up_wall.min_y - 7, c.BRIDGE))
    rand_x = randrange(c.COLUMNS + 5, int(4 * c.COLUMNS / 3) - 5)
    c.bridge_list.append(
        Obj(5 + rand_x, up_wall.min_y - 5, rand_x - 5, up_wall.min_y - 8,
            c.BRIDGE))
    rand_x = randrange(int(5 * c.COLUMNS / 3) + 1, 2 * c.COLUMNS - 2)
    c.bridge_list.append(
        Obj(rand_x + 1, up_wall.min_y - 6, rand_x - 1, up_wall.min_y - 8,
            c.BRIDGE))
    rand_x = randrange(2 * c.COLUMNS + 6, int((7 * c.COLUMNS) / 3) - 6)
    cross_bridge_list = [[' ' for _ in range(0, 15)] for _ in range(0, 15)]
    for x_pos in range(0, 15):
        for y_pos in range(15 - x_pos, 15):
            cross_bridge_list[x_pos][y_pos] = c.BRIDGE
    c.bridge_list.append(
        IrregularObjects(rand_x + 6, up_wall.min_y - 1, rand_x - 6,
                         up_wall.min_y - 14, cross_bridge_list))

    # Create extras
    mid = int((c.bridge_list[1].min_x + c.bridge_list[1].max_x) / 2)
    c.extras.append(
        Extras(mid + 1, c.bridge_list[1].max_y, mid - 1,
               c.bridge_list[1].min_y, c.EXTRAS_BRIDGE, get_extra()))
    mid = int((c.bridge_list[3].min_x + c.bridge_list[3].max_x) / 2)
    c.extras.append(
        Extras(mid + 1, c.bridge_list[3].max_y, mid - 1,
               c.bridge_list[3].min_y, c.EXTRAS_BRIDGE, get_extra()))

    # Create holes
    rand_x = randrange(int(c.COLUMNS / 3), int((2 * c.COLUMNS) / 3))
    print(down_wall.max_y - 2)
    print(len(c.DIMENSIONAL_ARRAY))
    c.holes_list.append(
        Obj(rand_x + 5, down_wall.max_y - 2, rand_x, up_wall.min_y, ' '))
    c.sub_holes_list.append(
        Obj(c.holes_list[0].max_x + 10, c.holes_list[0].max_y,
            c.holes_list[0].min_x, up_wall.min_y + 2, ' '))
    rand_x = randrange(
        int((4 * c.COLUMNS) / 3) + 4,
        int(5 * c.COLUMNS / 3) - 4)
    c.holes_list.append(Obj(rand_x + 4, c.ROWS, rand_x - 4, up_wall.min_y,
                            ' '))
    c.holes_list.append(
        Obj(c.bridge_list[5].max_x + 24, c.ROWS, c.bridge_list[5].max_x + 1,
            up_wall.min_y, ' '))

    # Create Coins
    mid = int((c.bridge_list[0].min_x + c.bridge_list[0].max_x) / 2)
    c.coins_list.append(
        Obj(mid, c.bridge_list[0].min_y - 1, mid, c.bridge_list[0].min_y - 1,
            c.COIN))
    mid = int((c.bridge_list[1].min_x + c.bridge_list[1].max_x) / 2)
    for x_pos, y_pos in zip(
            range(mid - 4, mid + 2, 2),
            range(c.bridge_list[1].min_y - 1, c.bridge_list[1].min_y - 4, -1)):
        c.coins_list.append(Obj(x_pos, y_pos, x_pos, y_pos, c.COIN))
    for x_pos, y_pos in zip(
            range(mid + 2, mid + 8, 2),
            range(c.bridge_list[1].min_y - 2, c.bridge_list[1].min_y, 1)):
        c.coins_list.append(Obj(x_pos, y_pos, x_pos, y_pos, c.COIN))
    print(c.sub_holes_list[0].max_x, c.sub_holes_list[0].max_y)

    c.coins_list.append(
        Obj(c.sub_holes_list[0].max_x, c.sub_holes_list[0].max_y,
            c.sub_holes_list[0].max_x, c.sub_holes_list[0].max_y, c.TIME))
    for x_pos in range(c.holes_list[0].max_x + 5, c.bridge_list[2].min_x - 5,
                       3):
        c.coins_list.append(
            Obj(x_pos, up_wall.min_y - 1, x_pos, up_wall.min_y - 1, c.COIN))

    # Create lake and fishes
    min_x = int(8 * c.COLUMNS / 3)
    max_x = int(11 * c.COLUMNS / 3)
    c.lakes.append(
        Obj(max_x, down_wall.max_y - 1, min_x, up_wall.max_y, c.WATER))
    rand_x = randrange(c.lakes[0].min_x + 2, c.lakes[0].max_x - 2)
    rand_y = c.lakes[0].min_y + randrange(1, 4)
    c.fishes.append(Obj(rand_x, rand_y, rand_x, rand_y, c.FISH))
    rand_x = randrange(c.lakes[0].min_x + 2, c.lakes[0].max_x - 2)
    rand_y = c.lakes[0].min_y + randrange(1, 4)
    c.fishes.append(Obj(rand_x, rand_y, rand_x, rand_y, c.FISH))

    # Generate Clouds
    cloud = print_cloud()
    rand_x = randrange(1, c.COLUMNS)
    rand_x_2 = randrange(c.COLUMNS, 2 * c.COLUMNS)
    rand_x_3 = randrange(2 * c.COLUMNS, 3 * c.COLUMNS)
    c.cloud_list.append(
        IrregularObjects(
            len(cloud[0]) + rand_x, 5 + len(cloud), rand_x, 1, cloud))
    c.cloud_list.append(
        IrregularObjects(
            len(cloud[0]) + rand_x_2, 4 + len(cloud), rand_x_2, 2, cloud))
    c.cloud_list.append(
        IrregularObjects(
            len(cloud[0]) + rand_x_3, 6 + len(cloud), rand_x_3, 1, cloud))

    # Create Enemies
    c.Enemies_list.append(
        Enemies(c.sub_holes_list[0].max_x - 2, c.sub_holes_list[0].max_y,
                c.sub_holes_list[0].max_x - 3, c.sub_holes_list[0].max_y - 1,
                c.ENEMY, c.sub_holes_list[0].min_x,
                c.sub_holes_list[0].max_x - 2))
    c.Enemies_list.append(
        Enemies(c.holes_list[1].min_x - 1, up_wall.min_y - 1,
                c.holes_list[1].min_x - 2, up_wall.min_y - 2, c.ENEMY,
                c.bridge_list[2].max_x + 1, c.holes_list[1].min_x - 1))
    c.Enemies_list.append(
        Enemies(c.bridge_list[3].max_x, c.bridge_list[3].min_y - 1,
                c.bridge_list[3].max_x - 1, c.bridge_list[3].min_y - 2,
                c.ENEMY, c.bridge_list[3].min_x, c.bridge_list[3].max_x))

    # Create enemies on bridges on lake
    mid = int((c.lakes[0].min_x + c.lakes[0].max_x) / 2)
    print(c.lakes[0].min_y, c.lakes[0].max_y)
    print('x_pos -> ', c.lakes[0].min_x + 5, mid, 10)
    print('y_pos-> ', c.lakes[0].min_y - 5, c.TOP - 3, int(c.ROWS / 10))
    # sleep(3)
    min_y = int(c.TOP + c.ROWS / 10)
    for x_pos, y_pos in zip(
            range(c.lakes[0].min_x + 5, mid, 10),
            range(c.lakes[0].min_y - 5, min_y, -int(c.ROWS / 10))):
        c.bridge_list.append(
            Obj(x_pos + 3, y_pos, x_pos - 3, y_pos - 1, c.BRIDGE))
        rand_x = randrange(x_pos - 3, x_pos + 3)
        c.Enemies_list.append(
            Enemies(rand_x + 1, y_pos - 2, rand_x, y_pos - 3, c.ENEMY,
                    x_pos - 3, x_pos + 3))
    store = c.bridge_list[-1]
    c.Enemies_list[-1].kill()
    c.Enemies_list.append(
        Enemies(store.max_x, store.min_y - 1, store.max_x - 1, store.min_y - 2,
                c.ENEMY, store.max_x - 1, store.max_x))

    for x_pos, y_pos in zip(
            range(c.lakes[0].max_x - 5, mid, -10),
            range(c.lakes[0].min_y - 5, min_y, -int(c.ROWS / 10))):
        c.bridge_list.append(
            Obj(x_pos + 3, y_pos, x_pos - 3, y_pos - 1, c.BRIDGE))
        rand_x = randrange(x_pos - 3, x_pos + 3)
        c.Enemies_list.append(
            Enemies(rand_x + 1, y_pos - 2, rand_x, y_pos - 3, c.ENEMY,
                    x_pos - 3, x_pos + 3))
    store_2 = c.bridge_list[-1]
    c.bridge_list.append(
        Obj(store_2.min_x, store.max_y, store.max_x, store.min_y, c.BRIDGE))
    c.Enemies_list[-1].kill()
    c.Enemies_list.append(
        Enemies(store_2.min_x + 1, store_2.min_y - 1, store_2.min_x,
                store_2.min_y - 2, c.ENEMY, store_2.min_x, store_2.min_x + 1))
    mid = int((store.max_x + store_2.min_x) / 2)
    c.life.append(Obj(mid, c.TOP, mid, c.TOP, c.LOVE))

    # Create moving bridges
    min_x = int((11 * c.COLUMNS) / 3) + 7
    length = 15
    max_x = int((9 * c.COLUMNS) / 2)

    # Create Knifes
    c.thrones_list.append(
        Obj(max_x, up_wall.max_y + 1, min_x, up_wall.max_y, c.THRONES))

    min_y = c.TOP + 5
    max_y = c.lakes[0].min_y - 5
    for x_pos in range(min_x, max_x, 25):
        rand_y = randrange(min_y, max_y + 1)
        c.moving_bridges.append(
            MovingBridges(x_pos + length, rand_y, x_pos, rand_y,
                          c.MOVING_BRIDGES, c.TOP + 5, c.lakes[0].min_y - 5))

    # moving_bridges.append(MovingBridges(lakes[0]))

    # Create the final pole
    c.pole.append(
        Obj(c.MAP_LENGTH - 5, up_wall.min_y - 1, c.MAP_LENGTH - 5,
            up_wall.min_y - 15, '|'))

    # Declare and start music
    c.control_music.append(Music())
    return up_wall, down_wall
Exemplo n.º 13
0
 def create_pole(self):
     # Dependencies: Walls
     self.pole = Obj(self.length - 5, self.up_wall.min_y - 1,
                     self.length - 5, self.up_wall.min_y - 15, '|',
                     self.map_array, self.object_array)
Exemplo n.º 14
0
    def create_enemies(self):
        """
        Dependencies: Holes, bridges, lakes, walls
        """
        self.enemies.append(
            Enemies(self.sub_holes[0].max_x - 2, self.sub_holes[0].max_y,
                    self.sub_holes[0].max_x - 3, self.sub_holes[0].max_y - 1,
                    config.ENEMY, self.sub_holes[0].min_x,
                    self.sub_holes[0].max_x - 2, self))
        self.enemies.append(
            Enemies(self.holes[1].min_x - 1, self.up_wall.min_y - 1,
                    self.holes[1].min_x - 2, self.up_wall.min_y - 2,
                    config.ENEMY, self.bridges[2].max_x + 1,
                    self.holes[1].min_x - 1, self))
        self.enemies.append(
            Enemies(self.bridges[3].max_x, self.bridges[3].min_y - 1,
                    self.bridges[3].max_x - 1, self.bridges[3].min_y - 2,
                    config.ENEMY, self.bridges[3].min_x, self.bridges[3].max_x,
                    self))

        # Create enemies and bridges on lake
        mid = int((self.lake.min_x + self.lake.max_x) / 2)
        print(self.lake.min_y, self.lake.max_y)
        # print('x_pos -> ', c.LAKES[0].min_x + 5, mid, 10)
        # print('y_pos-> ', c.LAKES[0].min_y - 5, c.TOP - 3, int(c.ROWS / 10))
        # sleep(3)
        min_y = int(config.TOP + self.rows / 10)
        for x_pos, y_pos in zip(
                range(self.lake.min_x + 5, mid, 10),
                range(self.lake.min_y - 5, min_y, -int(self.rows / 10))):
            self.bridges.append(
                Obj(x_pos + 3, y_pos, x_pos - 3, y_pos - 1, config.BRIDGE,
                    self.map_array, self.object_array))
            rand_x = randrange(x_pos - 3, x_pos + 3)
            self.enemies.append(
                Enemies(rand_x + 1, y_pos - 2, rand_x, y_pos - 3, config.ENEMY,
                        x_pos - 3, x_pos + 3, self))
        store = self.bridges[-1]
        self.enemies[-1].kill()
        self.enemies.append(
            Enemies(store.max_x, store.min_y - 1, store.max_x - 1,
                    store.min_y - 2, config.ENEMY, store.max_x - 1,
                    store.max_x, self))

        for x_pos, y_pos in zip(
                range(self.lake.max_x - 5, mid, -10),
                range(self.lake.min_y - 5, min_y, -int(self.rows / 10))):
            self.bridges.append(
                Obj(x_pos + 3, y_pos, x_pos - 3, y_pos - 1, config.BRIDGE,
                    self.map_array, self.object_array))
            rand_x = randrange(x_pos - 3, x_pos + 3)
            self.enemies.append(
                Enemies(rand_x + 1, y_pos - 2, rand_x, y_pos - 3, config.ENEMY,
                        x_pos - 3, x_pos + 3, self))
        store_2 = self.bridges[-1]
        self.bridges.append(
            Obj(store_2.min_x, store.max_y, store.max_x, store.min_y,
                config.BRIDGE, self.map_array, self.object_array))
        self.enemies[-1].kill()
        self.enemies.append(
            Enemies(store_2.min_x + 1, store_2.min_y - 1, store_2.min_x,
                    store_2.min_y - 2, config.ENEMY, store_2.min_x,
                    store_2.min_x + 1, self))
        mid = int((store.max_x + store_2.min_x) / 2)
        self.lives.append(
            Obj(mid, config.TOP, mid, config.TOP, config.LOVE, self.map_array,
                self.object_array))
Exemplo n.º 15
0
 def initialise_screen(self):
     Obj(self.screen['columns'], self.screen['rows'], 1, 3, ' ')
Exemplo n.º 16
0
def create_level1_map():
    """
    Initialises level 1 map of game
    :return:
    """
    # Create the ground for the PLAYER_OBJ
    down_wall = Obj(c.MAP_LENGTH, c.ROWS, 1, int((9 * c.ROWS) / 10),
                    c.DOWN_WALL)
    up_wall = Obj(c.MAP_LENGTH, down_wall.min_y - 1, 1, down_wall.min_y - 1,
                  c.UP_WALL)

    # Create bridges(some at random place and some at predefined place)
    c.BRIDGE_LIST.append(
        Obj(20, up_wall.min_y - 5, 14, up_wall.min_y - 7, c.BRIDGE))
    c.BRIDGE_LIST.append(
        Obj(40, up_wall.min_y - 5, 25, up_wall.min_y - 7, c.BRIDGE))
    c.BRIDGE_LIST.append(
        Obj(c.COLUMNS - 4, up_wall.min_y - 1, c.COLUMNS - 10,
            up_wall.min_y - 7, c.BRIDGE))
    rand_x = randrange(c.COLUMNS + 5, int(4 * c.COLUMNS / 3) - 5)
    c.BRIDGE_LIST.append(
        Obj(5 + rand_x, up_wall.min_y - 5, rand_x - 5, up_wall.min_y - 8,
            c.BRIDGE))
    rand_x = randrange(int(5 * c.COLUMNS / 3) + 1, 2 * c.COLUMNS - 2)
    c.BRIDGE_LIST.append(
        Obj(rand_x + 1, up_wall.min_y - 6, rand_x - 1, up_wall.min_y - 8,
            c.BRIDGE))
    rand_x = randrange(2 * c.COLUMNS + 6, int((7 * c.COLUMNS) / 3) - 6)
    cross_bridge_list = [[' ' for _ in range(0, 15)] for _ in range(0, 15)]
    for x_pos in range(0, 15):
        for y_pos in range(15 - x_pos, 15):
            cross_bridge_list[x_pos][y_pos] = c.BRIDGE
    c.BRIDGE_LIST.append(
        IrregularObjects(
            {
                'max_x': rand_x + 6,
                'max_y': up_wall.min_y - 1,
                'min_x': rand_x - 6,
                'min_y': up_wall.min_y - 14
            }, cross_bridge_list))

    # Create EXTRAS
    mid = int((c.BRIDGE_LIST[1].min_x + c.BRIDGE_LIST[1].max_x) / 2)
    c.EXTRAS.append(
        Extras(mid + 1, c.BRIDGE_LIST[1].max_y, mid - 1,
               c.BRIDGE_LIST[1].min_y, c.EXTRAS_BRIDGE, get_extra()))
    mid = int((c.BRIDGE_LIST[3].min_x + c.BRIDGE_LIST[3].max_x) / 2)
    c.EXTRAS.append(
        Extras(mid + 1, c.BRIDGE_LIST[3].max_y, mid - 1,
               c.BRIDGE_LIST[3].min_y, c.EXTRAS_BRIDGE, get_extra()))

    # Create holes
    rand_x = randrange(int(c.COLUMNS / 3), int((2 * c.COLUMNS) / 3))
    c.HOLES_LIST.append(
        Obj(rand_x + 5, down_wall.max_y - 2, rand_x, up_wall.min_y, ' '))
    c.SUB_HOLES_LIST.append(
        Obj(c.HOLES_LIST[0].max_x + 10, c.HOLES_LIST[0].max_y,
            c.HOLES_LIST[0].min_x, up_wall.min_y + 2, ' '))
    rand_x = randrange(
        int((4 * c.COLUMNS) / 3) + 4,
        int(5 * c.COLUMNS / 3) - 4)
    c.HOLES_LIST.append(Obj(rand_x + 4, c.ROWS, rand_x - 4, up_wall.min_y,
                            ' '))
    c.HOLES_LIST.append(
        Obj(c.BRIDGE_LIST[5].max_x + 24, c.ROWS, c.BRIDGE_LIST[5].max_x + 1,
            up_wall.min_y, ' '))

    # Create Coins
    mid = int((c.BRIDGE_LIST[0].min_x + c.BRIDGE_LIST[0].max_x) / 2)
    c.COINS_LIST.append(
        Obj(mid, c.BRIDGE_LIST[0].min_y - 1, mid, c.BRIDGE_LIST[0].min_y - 1,
            c.COIN))
    mid = int((c.BRIDGE_LIST[1].min_x + c.BRIDGE_LIST[1].max_x) / 2)
    for x_pos, y_pos in zip(
            range(mid - 4, mid + 2, 2),
            range(c.BRIDGE_LIST[1].min_y - 1, c.BRIDGE_LIST[1].min_y - 4, -1)):
        c.COINS_LIST.append(Obj(x_pos, y_pos, x_pos, y_pos, c.COIN))
    for x_pos, y_pos in zip(
            range(mid + 2, mid + 8, 2),
            range(c.BRIDGE_LIST[1].min_y - 2, c.BRIDGE_LIST[1].min_y, 1)):
        c.COINS_LIST.append(Obj(x_pos, y_pos, x_pos, y_pos, c.COIN))
    print(c.SUB_HOLES_LIST[0].max_x, c.SUB_HOLES_LIST[0].max_y)

    c.COINS_LIST.append(
        Obj(c.SUB_HOLES_LIST[0].max_x, c.SUB_HOLES_LIST[0].max_y,
            c.SUB_HOLES_LIST[0].max_x, c.SUB_HOLES_LIST[0].max_y, c.TIME))
    for x_pos in range(c.HOLES_LIST[0].max_x + 5, c.BRIDGE_LIST[2].min_x - 5,
                       3):
        c.COINS_LIST.append(
            Obj(x_pos, up_wall.min_y - 1, x_pos, up_wall.min_y - 1, c.COIN))

    # Create lake and FISHES
    min_x = int(8 * c.COLUMNS / 3)
    max_x = int(11 * c.COLUMNS / 3)
    c.LAKES.append(
        Obj(max_x, down_wall.max_y - 1, min_x, up_wall.max_y, c.WATER))
    rand_x = randrange(c.LAKES[0].min_x + 2, c.LAKES[0].max_x - 2)
    rand_y = c.LAKES[0].min_y + randrange(1, 4)
    c.FISHES.append(Obj(rand_x, rand_y, rand_x, rand_y, c.FISH))
    rand_x = randrange(c.LAKES[0].min_x + 2, c.LAKES[0].max_x - 2)
    rand_y = c.LAKES[0].min_y + randrange(1, 4)
    c.FISHES.append(Obj(rand_x, rand_y, rand_x, rand_y, c.FISH))

    # Generate Clouds
    cloud = print_cloud()
    rand_x = randrange(1, c.COLUMNS)
    rand_x_2 = randrange(c.COLUMNS, 2 * c.COLUMNS)
    rand_x_3 = randrange(2 * c.COLUMNS, 3 * c.COLUMNS)
    c.CLOUD_LIST.append(
        IrregularObjects(
            {
                'max_x': len(cloud[0]) + rand_x,
                'max_y': 5 + len(cloud),
                'min_x': rand_x,
                'min_y': 1
            }, cloud))
    c.CLOUD_LIST.append(
        IrregularObjects(
            {
                'max_x': len(cloud[0]) + rand_x_2,
                'max_y': 4 + len(cloud),
                'min_x': rand_x_2,
                'min_y': 2
            }, cloud))
    c.CLOUD_LIST.append(
        IrregularObjects(
            {
                'max_x': len(cloud[0]) + rand_x_3,
                'max_y': 6 + len(cloud),
                'min_x': rand_x_3,
                'min_y': 1
            }, cloud))

    # Create Enemies
    c.ENEMIES_LIST.append(
        Enemies(c.SUB_HOLES_LIST[0].max_x - 2, c.SUB_HOLES_LIST[0].max_y,
                c.SUB_HOLES_LIST[0].max_x - 3, c.SUB_HOLES_LIST[0].max_y - 1,
                c.ENEMY, c.SUB_HOLES_LIST[0].min_x,
                c.SUB_HOLES_LIST[0].max_x - 2))
    c.ENEMIES_LIST.append(
        Enemies(c.HOLES_LIST[1].min_x - 1, up_wall.min_y - 1,
                c.HOLES_LIST[1].min_x - 2, up_wall.min_y - 2, c.ENEMY,
                c.BRIDGE_LIST[2].max_x + 1, c.HOLES_LIST[1].min_x - 1))
    c.ENEMIES_LIST.append(
        Enemies(c.BRIDGE_LIST[3].max_x, c.BRIDGE_LIST[3].min_y - 1,
                c.BRIDGE_LIST[3].max_x - 1, c.BRIDGE_LIST[3].min_y - 2,
                c.ENEMY, c.BRIDGE_LIST[3].min_x, c.BRIDGE_LIST[3].max_x))

    # Create enemies and bridges on lake
    mid = int((c.LAKES[0].min_x + c.LAKES[0].max_x) / 2)
    print(c.LAKES[0].min_y, c.LAKES[0].max_y)
    print('x_pos -> ', c.LAKES[0].min_x + 5, mid, 10)
    print('y_pos-> ', c.LAKES[0].min_y - 5, c.TOP - 3, int(c.ROWS / 10))
    # sleep(3)
    min_y = int(c.TOP + c.ROWS / 10)
    for x_pos, y_pos in zip(
            range(c.LAKES[0].min_x + 5, mid, 10),
            range(c.LAKES[0].min_y - 5, min_y, -int(c.ROWS / 10))):
        c.BRIDGE_LIST.append(
            Obj(x_pos + 3, y_pos, x_pos - 3, y_pos - 1, c.BRIDGE))
        rand_x = randrange(x_pos - 3, x_pos + 3)
        c.ENEMIES_LIST.append(
            Enemies(rand_x + 1, y_pos - 2, rand_x, y_pos - 3, c.ENEMY,
                    x_pos - 3, x_pos + 3))
    store = c.BRIDGE_LIST[-1]
    c.ENEMIES_LIST[-1].kill()
    c.ENEMIES_LIST.append(
        Enemies(store.max_x, store.min_y - 1, store.max_x - 1, store.min_y - 2,
                c.ENEMY, store.max_x - 1, store.max_x))

    for x_pos, y_pos in zip(
            range(c.LAKES[0].max_x - 5, mid, -10),
            range(c.LAKES[0].min_y - 5, min_y, -int(c.ROWS / 10))):
        c.BRIDGE_LIST.append(
            Obj(x_pos + 3, y_pos, x_pos - 3, y_pos - 1, c.BRIDGE))
        rand_x = randrange(x_pos - 3, x_pos + 3)
        c.ENEMIES_LIST.append(
            Enemies(rand_x + 1, y_pos - 2, rand_x, y_pos - 3, c.ENEMY,
                    x_pos - 3, x_pos + 3))
    store_2 = c.BRIDGE_LIST[-1]
    c.BRIDGE_LIST.append(
        Obj(store_2.min_x, store.max_y, store.max_x, store.min_y, c.BRIDGE))
    c.ENEMIES_LIST[-1].kill()
    c.ENEMIES_LIST.append(
        Enemies(store_2.min_x + 1, store_2.min_y - 1, store_2.min_x,
                store_2.min_y - 2, c.ENEMY, store_2.min_x, store_2.min_x + 1))
    mid = int((store.max_x + store_2.min_x) / 2)
    c.LIFE.append(Obj(mid, c.TOP, mid, c.TOP, c.LOVE))

    # Create moving bridges
    min_x = int((11 * c.COLUMNS) / 3) + 7
    length = 15
    max_x = int((9 * c.COLUMNS) / 2)

    # Create Knifes
    c.THRONES_LIST.append(
        Obj(max_x, up_wall.max_y + 1, min_x, up_wall.max_y, c.THRONES))

    min_y = c.TOP + 5
    max_y = c.LAKES[0].min_y - 5
    for x_pos in range(min_x, max_x, 25):
        rand_y = randrange(min_y, max_y + 1)
        c.MOVING_BRIDGES_OBJ.append(
            MovingBridges(x_pos + length, rand_y, x_pos, rand_y,
                          c.MOVING_BRIDGES, c.TOP + 5, c.LAKES[0].min_y - 5))

    # MOVING_BRIDGES_OBJ.append(MovingBridges(LAKES[0]))

    # Create the final POLE
    c.POLE.append(
        Obj(c.MAP_LENGTH - 5, up_wall.min_y - 1, c.MAP_LENGTH - 5,
            up_wall.min_y - 15, '|'))

    # Declare and start music
    c.CONTROL_MUSIC.append(Music())
    return up_wall, down_wall