Example #1
0
def make_dungeon_map2():
    #0  1   2   3   4   5   6   7   8
    num_monsters = [0, 10, 20, 30, 10, 30, 10, 20, 0]
    size = [0, 10, 20, 30, 10, 30, 10, 20, 0]
    generated = rooms.generate_level(
        size[game.dungeon_level], rooms.room_templates[game.dungeon_level - 1])
    level = Level(generated.width(), generated.height())
    level.tiles = generated
    level.blocked = level.tiles.equals(Tile.WALL)
    if game.dungeon_level == 3:
        level.create_river(Tile.WATER)
    elif game.dungeon_level == 5:
        level.create_river(Tile.LAVA)
    #level.blocked.print_ascii('.#')

    x, y = level.tiles.find_random(Tile.FLOOR)
    level.stairs = actors.Actor(x,
                                y,
                                graphics.stairs_for_level[game.dungeon_level],
                                'stairs',
                                rl.WHITE,
                                always_visible=True,
                                z=-2)
    level.objects = [player, level.stairs]
    player.x, player.y = level.tiles.find_random(Tile.FLOOR)
    for i in range(num_monsters[game.dungeon_level]):
        name = monsters.random_choice(monsters.get_monster_chances())
        while True:
            x, y = level.tiles.find_random(Tile.FLOOR)
            if player.distance(x, y) > player.sight_radius:
                break
        level.objects.append(monsters.make_monster(name, x, y))
    level.compute_fov()
    return level
Example #2
0
def load_and_print(time, time_delta, time_info, journies, total_time, palette):
    active_j = filter(
        lambda x: x[0] <= time + time_delta and x[1] > time + time_delta,
        journies)
    print "printing frame %d / %d (%d)" % (time, total_time, len(active_j))
    print_frame(time, time_delta, time_info, palette,
                [actors.Actor(j, palette) for j in active_j])
Example #3
0
 def __init__(self, template):
     super().__init__(template)
     captain = actors.Actor('Haral', 'Mercer')
     captain.description = 'a strong, heavily bearded man, who has obviously seen a lot of combat'
     captain.job = 'guard captain'
     self.actors = {}
     self.actors['captain'] = captain
     self.gameState.actors['captain'] = captain
     self.addEvent(events.Narration("Inside, sitting in a chair by the fire singing a loud bawdy song is captain Larode. He appears to have been drinking, and also appears to be missing the lower part of his left leg.")) 
Example #4
0
def make_boss_map():
    level = Level(const.MAP_WIDTH, const.MAP_HEIGHT)
    level.tiles.fill(Tile.BOSS_WALL)
    level.blocked.fill(1)

    center_x = level.width // 2
    center_y = level.height // 2
    level.create_room(Rect(center_x - 20, center_y - 20, 40, 40),
                      Tile.BOSS_FLOOR)
    level.create_room(Rect(center_x - 30, center_y - 3, 6, 6), Tile.BOSS_FLOOR)
    level.create_h_tunnel(center_x - 24, center_x - 20, center_y,
                          Tile.BOSS_FLOOR)
    level.fill_circle(center_x, center_y, 6, Tile.BOSS_CARPET)
    for angle in range(0, 360, 15):
        x = math.cos(math.pi * angle / 180) * 12 + center_x + 0.5
        y = math.sin(math.pi * angle / 180) * 12 + center_y + 0.5
        level[int(x), int(y)] = Tile.mapping[Tile.BOSS_WALL]

    for angle in range(0, 360, 45):
        x = math.cos(math.pi * angle / 180) * 6 + center_x + 0.5
        y = math.sin(math.pi * angle / 180) * 6 + center_y + 0.5
        level[int(x), int(y)] = Tile.mapping[Tile.BOSS_WALL]

    player.x = center_x - 27
    player.y = center_y - 1
    amulet = actors.Actor(center_x + 3, center_y, graphics.YENDOR_AMULET,
                          'Amulet of Yendor', rl.YELLOW)

    # need stairs to save game
    level.stairs = actors.Actor(0,
                                0,
                                graphics.ROCK_STAIRS,
                                'stairs',
                                rl.WHITE,
                                always_visible=True,
                                z=-2)
    level.objects = [level.stairs, amulet, player]

    level.objects.append(
        monsters.make_monster('original-body', center_x, center_y))
    level.objects.append(
        monsters.make_monster('nuphrindas', center_x - 3, center_y))
    level.compute_fov()
    return level
Example #5
0
 def __init__(self, template):
     super().__init__(template)
     actorGateGuard = actors.Actor('Arsan Hingel', 'Arsan')
     actorGateGuard.description = 'a tall and wiry man with roughly cut blond hair and thin lips'
     actorGateGuard.job = 'guard'
     self.actors = {}
     self.actors['gateGuard'] = actorGateGuard
     self.gameState.actors['gateGuard'] = actorGateGuard
     self.addEvent(events.Narration("It is a grey and windy afternoon when your party sights the stronghold silhouetted on a ridge. This outpost, seated before the great snowy mountains of the North, and overlooking the rolling hills and forests of the wild-lands is to be your home. Remembering the attack on your party, you suddenly realise how vulnerable you are outside its walls.")) 
     self.addEvent(events.Narration("The path up from the valley floor winds back and forth, and the horses plod the last stretch up to the gates. The guard slouched by the open gate walks up to greet you. He is " + actorGateGuard.description + " who introduces himself as " + actorGateGuard.name + "."))
     self.addEvent(events.Narration('"Welcome to Hyree commander, we could do with some help."'))
     self.addEvent(events.GetUserChoice("Do you respond with...", [('Charisma', self.cCharisma), ('Seriousness', self.cSerious), ('Caution', self.cCaution)]))
Example #6
0
def make_forest_map():
    level = Level(const.MAP_WIDTH, const.MAP_HEIGHT)
    level.tiles.fill(Tile.GRASS)
    level.blocked.fill(0)

    center_x = level.width // 2
    center_y = level.height // 2
    radius = min([center_x, center_y])

    def contains_tree(x, y):
        d = math.sqrt((x - center_x)**2 + (y - center_y)**2)
        if d < 3:
            return False
        if d >= radius:
            return True
        p = 100 * d / radius
        v = rl.random_int(0, 100)
        return v < p

    level.objects = [player]
    player.x = center_x
    player.y = center_y
    for y in range(level.height):
        for x in range(level.width):
            if contains_tree(x, y):
                level[x, y] = Tile.mapping[Tile.WALL]
                #level.objects.append(actors.Actor(x, y, graphics.TREE, 'tree', rl.GREEN, always_visible=True))
                #level.blocked[x, y] = 1
    level.blocked = level.tiles.equals(Tile.WALL)

    angle = rl.random_int(0, 360)
    distance = rl.random_int(2, 3)
    level.stairs = actors.Actor(center_x + int(distance * math.cos(angle)),
                                center_y + int(distance * math.sin(angle)),
                                graphics.ROCK_STAIRS,
                                'stairs',
                                rl.WHITE,
                                always_visible=True,
                                z=-2)
    level.objects.append(level.stairs)
    level.compute_fov()

    #distance = level.blocked.copy()
    #distance.replace(0, rl.INT_MAX)
    #distance.replace(1, -1)
    #distance[player.x, player.y] = 0
    #distance.dijkstra()
    #distance.replace(rl.INT_MAX, -1)
    #print(distance.max(), distance.argmax())

    return level
Example #7
0
def make_dungeon_map():
    level = Level(const.MAP_WIDTH, const.MAP_HEIGHT)
    level.tiles.fill(Tile.WALL)
    level.blocked.fill(1)
    level.objects = [player]

    rooms = []
    num_rooms = 0

    for r in range(const.MAX_ROOMS):
        if num_rooms == 0:
            w = rl.random_int(const.ROOM_MIN_SIZE - 1, const.ROOM_MIN_SIZE + 2)
            h = rl.random_int(const.ROOM_MIN_SIZE - 1, const.ROOM_MIN_SIZE + 2)
        else:
            w = rl.random_int(const.ROOM_MIN_SIZE, const.ROOM_MAX_SIZE)
            h = rl.random_int(const.ROOM_MIN_SIZE, const.ROOM_MAX_SIZE)

        x = rl.random_int(0, level.width - w - 1)
        y = rl.random_int(0, level.height - h - 1)

        new_room = Rect(x, y, w, h)

        failed = False
        for other_room in rooms:
            if new_room.intersect(other_room):
                failed = True
                break

        if not failed:
            level.create_room(new_room)
            (new_x, new_y) = new_room.center()

            if num_rooms == 0:
                player.x = new_x
                player.y = new_y
            else:
                (prev_x, prev_y) = rooms[num_rooms - 1].center()

                if rl.random_int(0, 1) == 1:
                    level.create_h_tunnel(prev_x, new_x, prev_y)
                    level.create_v_tunnel(prev_y, new_y, new_x)
                else:
                    level.create_v_tunnel(prev_y, new_y, prev_x)
                    level.create_h_tunnel(prev_x, new_x, new_y)

                monsters.place_objects(level, new_room)

            rooms.append(new_room)
            num_rooms += 1

    if game.dungeon_level == 3:
        level.create_river(Tile.WATER)
    elif game.dungeon_level == 5:
        level.create_river(Tile.LAVA)

    level.stairs = actors.Actor(new_x,
                                new_y,
                                graphics.stairs_for_level[game.dungeon_level],
                                'stairs',
                                rl.WHITE,
                                always_visible=True,
                                z=-2)
    level.objects.append(level.stairs)
    level.compute_fov()
    return level