コード例 #1
0
ファイル: main.py プロジェクト: yeahpython/bees-bees-bees
def preparelevel(screen, level):
    if level == "random map":
        return prepareRandomLevel(screen)
    elif level == "Random 35 x 35":
        return prepareRandomLevel(screen, 35, 35)
    elif level == "Random 60 x 60":
        return prepareRandomLevel(screen, 60, 60)
    elif level == "Random 60 x 25":
        return prepareRandomLevel(screen, 60, 25)
    else:
        levelname = os.path.join("data", "rooms", level)
        graphics.load(levelname)
        world = pygame.Surface((graphics.world_w, graphics.world_h))
        t = topbar.TopBar(screen)
        r = room.load(levelname)
        test.mark(r.background)
        r.topbar = t
        return world, t, r
コード例 #2
0
ファイル: main.py プロジェクト: yeahpython/bees-bees-bees
def prepareRandomLevel(screen, cols=0, rows=0):
    messages.colorBackground()
    if not cols:
        cols = int(getChoiceUnbounded("Room width?", [str(x) for x in range(30, 61, 5)]))
    if not rows:
        rows = int(getChoiceUnbounded("Room height?", [str(x) for x in range(20, 61, 5)]))
    room.globalize_dimensions(rows, cols)

    lines = [" " * cols for x in range(rows + 1)]
    room.randomlymodify(lines)
    tiles = []
    for c in range(cols):
        tiles.append([])
        for r in range(rows):
            tiles[c].append(tile.tile[lines[r][c]])
    r = room.Room(tiles, lines)
    graphics.extract_dimensions(lines)

    world = pygame.Surface((graphics.world_w, graphics.world_h))
    t = topbar.TopBar(screen)
    test.mark(r.background)
    r.topbar = t
    return world, t, r