Exemplo n.º 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
Exemplo n.º 2
0
 def new(self):
     controllers.Player.keys = [] # reset any pending keystroke
     self.current = 0
     self.dungeon_level = -1
     builtins.player = monsters.make_monster('ghoul', 0, 0)
     self.next_level()
     player.push_controller(controllers.Player())
     self.state = 'playing'
     ui.message('Starting game')
Exemplo n.º 3
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
Exemplo n.º 4
0
 def summon_monster(name):
     print(name)
     x, y = 0, 0
     i = 0
     while i < 100:
         angle = rl.random_int(0, 359)
         distance = rl.random_int(2, 4)
         x = int(caster.x + .5 + math.cos(math.pi * angle / 180) * distance)
         y = int(caster.y + .5 + math.sin(math.pi * angle / 180) * distance)
         print(x, y)
         if not level.is_blocked(x, y) and caster.can_see_tile(x, y):
             break
         i += 1
     if i == 100:
         if caster is player:
             ui.message('You fail to cast the summon spell.', rl.BLUE)
     monster = monsters.make_monster(name, x, y)
     if not hostile:
         monster.master = caster
     level.objects.append(monster)
     if caster is player or player.can_see(caster) or player.can_see(monster):
         ui.message(util.capitalize(caster.get_name('summon{s}')) + ' ' + monster.get_name(determiner='a') + '.', rl.BLUE)
Exemplo n.º 5
0
 def callback(index):
     game.pop_scene()
     player.pop_controller()
     builtins.player = monsters.make_monster(options[index], 0, 0)
     player.push_controller(controllers.Player())
     game.push_scene(scenes.Ending())