Beispiel #1
0
def draw_death_screen(dest, W, H):
    DEATH = Surface((W, H))
    tk.draw_sentance(DEATH, "You died", (64, 64), PW=3)
    tk.draw_sentance(DEATH,
                     "The Temple of LURD claims another life", (96, 128),
                     PW=1)
    dest.blit(DEATH, (0, 0))
Beispiel #2
0
def loading_screen_update(dest, percentage):
    dest.fill(BLACK)
    string = "Loading... " + str(percentage) + "%"
    tk.draw_sentance(dest, string, (0, 0), PW=3)
    for e in pygame.event.get():
        if e.type == pygame.locals.QUIT: quit()
    pygame.display.update()
Beispiel #3
0
def pathfinder(grid, ent, ext, debug_surf=False):
    """
    fill the grid with stone until it isn't solvable anymore
    then undo the last stones placed
    repeat until the whole grid is accounted for

    optomized by applying more stone while the number of slots is larger
    """
    slots = list(
        filter(lambda pos: not grid[pos[1]][pos[0]],
               [(x, y) for x in range(len(grid[0]))
                for y in range(len(grid))]))
    while slots:
        new = []
        for _ in range((len(slots) // 10) + 1):
            x, y = choice(slots)
            grid[y][x].append("stone")
            slots.remove((x, y))
            new.append((x, y))
        check, touched = solvable(grid, ent, ext)
        if not check:
            for (x, y) in new:
                grid[y][x].pop()
                grid[y][x].append("floor")
        else:
            for x, y in slots:
                if (x, y) not in touched:
                    grid[y][x].append("stone")
                    slots.remove((x, y))
        if debug_surf:
            debug_floor(debug_surf, grid)
            tk.draw_sentance(debug_surf, "len slots: " + str(len(slots)),
                             (0, 32 * 15))
            pygame.display.update()
Beispiel #4
0
def draw_victory_screen(dest, W, H):
    VICTORY = Surface((W, H))
    tk.draw_sentance(VICTORY, "You did it", (64, 64), PW=3)
    tk.draw_sentance(VICTORY,
                     "You escaped the Temple of LURD", (96, 128),
                     PW=1)
    tk.draw_token(VICTORY, "face", (96, 192), col2=GREEN, PW=5)
    dest.blit(VICTORY, (0, 0))
Beispiel #5
0
def draw_log(dest, pos, G, num_entries=4):
    LOG = Surface((512, num_entries * 16))
    LOG.fill((1, 255, 1))
    for i, entry in enumerate(G["LOG"][0 - num_entries:]):
        tk.draw_sentance(LOG,
                         entry, (0, i * 16),
                         col1=(1, 255, 1),
                         col2=WHITE,
                         PW=1)
    LOG.set_colorkey((1, 255, 1))
    dest.blit(LOG, pos)
Beispiel #6
0
def draw_INV(dest, pos, player, search=None):
    INV = Surface((512, len(player["INV"]) * 16))
    INV.fill(GRAY)
    idx = "0123456789abcdefghijklmnopqrstuvwxyz"
    for i, item in enumerate(player["INV"]):
        if search in item["TRAITS"]:
            col2 = LIGHTGREEN
        else:
            col2 = WHITE

        tk.draw_sentance(INV,
                         idx[i] + ": " + item["NAME"], (0, i * 16),
                         col1=GRAY,
                         col2=col2,
                         PW=1)
    dest.blit(INV, pos)
Beispiel #7
0
def setup_game(limit, debug):
    G = {}
    D, I, A, T = builder.build(SCREEN, limit=limit, debug=debug)
    G["DUNGEON"] = D
    G["ITEMS"] = I
    G["ACTORS"] = A
    G["THEMES"] = T
    G["LIT"] = [set() for floor in G["DUNGEON"]]
    G["FLOOR"] = 0
    G["PW"] = 4

    G["LOG"] = []
    
    SCREEN.fill(BLACK)
    tk.draw_sentance(SCREEN, "Done.", (0, 0), PW=3)
    return G
Beispiel #8
0
def draw_setup_menu(dest, W, H, LIMIT=15, DEBUG=False, selected=0):
    MENU = Surface((W, H))
    MENU.fill(BLACK)
    tk.draw_sentance(
        MENU,
        "The Temple of LURD 2",
        (32, 32),
        PW=3,
    )
    tk.draw_sentance(MENU, "a RogueLike by Wesley :)", (96, 128), PW=2)
    tk.draw_sentance(MENU, "Floors :", (128, 256), PW=2)
    tk.draw_sentance(MENU,
                     str(LIMIT), (576, 256),
                     col2=[LIGHTGREEN, WHITE, WHITE, WHITE][selected],
                     PW=2)
    tk.draw_sentance(MENU, "Debug mode :", (128, 320), PW=2)
    tk.draw_sentance(MENU,
                     str(DEBUG), (576, 320),
                     col2=[WHITE, LIGHTGREEN, WHITE, WHITE][selected],
                     PW=2)
    tk.draw_sentance(MENU,
                     "Begin", (576, 384),
                     col2=[WHITE, WHITE, LIGHTGREEN, WHITE][selected],
                     PW=2)
    tk.draw_sentance(MENU,
                     "Exit", (576, 448),
                     col2=[WHITE, WHITE, WHITE, LIGHTGREEN][selected],
                     PW=2)
    dest.blit(MENU, (0, 0))
Beispiel #9
0
def draw_HUD(dest, G, player):
    PLAYER_INFO = Surface((1024, 64))
    PLAYER_INFO.fill((1, 255, 1))
    # Health Bar
    HP = player["HP"]
    MAX = player["HPMAX"]
    teenth = MAX / 16
    string = str(HP) + "/" + str(MAX)
    for n in range(16):
        col = RED if n * teenth <= HP else LIGHTGRAY
        if n < len(string):
            if string[n] in tk.CHARACTER_MAP:
                token = tk.CHARACTER_MAP[string[n]]
            else:
                token = string[n]
            tk.draw_token(PLAYER_INFO,
                          token, (n * 32, 0),
                          col1=col,
                          col2=BLACK,
                          PW=2)
        else:
            tk.draw_token(PLAYER_INFO,
                          "base", (n * 32, 0),
                          col1=col,
                          col2=BLACK,
                          PW=2)
    string = "LEVEL: " + str(player["LVL"])
    tk.draw_sentance(PLAYER_INFO,
                     string, (0, 32),
                     col1=(1, 255, 1),
                     col2=WHITE,
                     PW=1)
    string = "EXP: " + str(player["EXP"])
    tk.draw_sentance(PLAYER_INFO,
                     string, (0, 48),
                     col1=(1, 255, 1),
                     col2=WHITE,
                     PW=1)
    string = "ATTACK: " + str(player["ATK"])
    tk.draw_sentance(PLAYER_INFO,
                     string, (192, 32),
                     col1=(1, 255, 1),
                     col2=WHITE,
                     PW=1)
    string = "DEFENCE: " + str(player["DEF"])
    tk.draw_sentance(PLAYER_INFO,
                     string, (192, 48),
                     col1=(1, 255, 1),
                     col2=WHITE,
                     PW=1)
    if player["WEAPON"]:
        string = "WEAPON: " + player["WEAPON"]["NAME"]
    else:
        string = "WEAPON: None"
    tk.draw_sentance(PLAYER_INFO,
                     string, (512, 0),
                     col1=(1, 255, 1),
                     col2=WHITE,
                     PW=1)
    if player["ARMOR"]:
        string = "ARMOR: " + player["ARMOR"]["NAME"]
    else:
        string = "ARMOR: None"
    tk.draw_sentance(PLAYER_INFO,
                     string, (512, 16),
                     col1=(1, 255, 1),
                     col2=WHITE,
                     PW=1)
    string = "FLOOR: " + str(G["FLOOR"])
    tk.draw_sentance(PLAYER_INFO,
                     string, (512, 32),
                     col1=(1, 255, 1),
                     col2=WHITE,
                     PW=1)
    string = G["THEMES"][G["FLOOR"]]
    tk.draw_sentance(PLAYER_INFO,
                     string, (512, 48),
                     col1=(1, 255, 1),
                     col2=WHITE,
                     PW=1)

    PLAYER_INFO.set_colorkey((1, 255, 1))
    dest.blit(PLAYER_INFO, (0, 0))
Beispiel #10
0
def build(screen, startingfloor=STARTINGFLOOR, limit=15, debug=False):
    """
    > actually writing docstrings

    so im thinking each floor will be a 2d array
    each cell in the 2d array will be a stack of strings
    the strings must have a token representation
    """
    if debug: debug = screen
    loading_screen_update(screen, 0)
    floors = [STARTINGFLOOR]
    items = [[
        its.make_sword("DEFAULT", (3, 4)),
        its.make_shield("DEFAULT", (5, 4))
    ]]
    actors = [[]]
    levelthemes = ["DEFAULT"]
    ext = (5, 5)
    themelist = list(themes.THEME_MAP.keys())
    themelist.remove("DEFAULT")
    for i in range(limit):
        loading_screen_update(screen, int((i / (limit + 1)) * 100))

        W, H = (i * 3) + randint(25, 30), (i * 3) + randint(25, 30)
        W, H = max(W, ext[0] + 2), max(H, ext[1] + 2)
        ent = ext
        while distance(ent, ext) < (max(W, H) // 3) * 2:
            ext = randint(2, W - 2), randint(2, H - 2)

        items.append([])
        actors.append([])

        theme = choice(themelist)

        levelthemes.append(theme)

        floor = fresh_floor(W, H, ent=ent, ext=ext)
        tk.draw_sentance(screen, "Making rooms...", (0, 48), PW=1)
        pygame.display.update()
        apply_rooms(floor, THEME=theme, debug_surf=debug)
        tk.draw_sentance(screen, "Pathfinding...", (0, 48 + 16), PW=1)
        pygame.display.update()
        pathfinder(floor, ent, ext, debug_surf=debug)
        tk.draw_sentance(screen, "Carving...", (0, 48 + 32), PW=1)
        pygame.display.update()
        carve(floor, debug_surf=debug)

        frame = []
        for y in range(H + 2):
            frame.append([])
            for x in range(W + 2):
                if x in [0, W + 1] or y in [0, H + 1]:
                    frame[-1].append(["stone"])
                else:
                    frame[-1].append([])

        insert_grid(frame, floor, (1, 1))
        tk.draw_sentance(screen, "Populating...", (0, 48 + 48), PW=1)
        pygame.display.update()
        populate(frame, items[-1], actors[-1], theme=theme)
        floors.append(frame)
    return floors, items, actors, levelthemes