예제 #1
0
def test_image(console, tmpdir):
    img = libtcodpy.image_new(16, 16)
    libtcodpy.image_clear(img, libtcodpy.Color(0, 0, 0))
    libtcodpy.image_invert(img)
    libtcodpy.image_hflip(img)
    libtcodpy.image_rotate90(img)
    libtcodpy.image_vflip(img)
    libtcodpy.image_scale(img, 24, 24)
    libtcodpy.image_set_key_color(img, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_get_alpha(img, 0, 0)
    libtcodpy.image_is_pixel_transparent(img, 0, 0)
    libtcodpy.image_get_size(img)
    libtcodpy.image_get_pixel(img, 0, 0)
    libtcodpy.image_get_mipmap_pixel(img, 0, 0, 1, 1)
    libtcodpy.image_put_pixel(img, 0, 0, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_blit(img, console, 0, 0,
                         libtcodpy.BKGND_SET, 1, 1, 0)
    libtcodpy.image_blit_rect(img, console, 0, 0, 16, 16,
                              libtcodpy.BKGND_SET)
    libtcodpy.image_blit_2x(img, console, 0, 0)
    libtcodpy.image_save(img, tmpdir.join('test.png').strpath)
    libtcodpy.image_delete(img)

    img = libtcodpy.image_from_console(console)
    libtcodpy.image_refresh_console(img, console)
    libtcodpy.image_delete(img)

    libtcodpy.image_delete(libtcodpy.image_load('libtcod/data/img/circle.png'))
예제 #2
0
def test_image(console, tmpdir):
    img = libtcodpy.image_new(16, 16)
    libtcodpy.image_clear(img, libtcodpy.Color(0, 0, 0))
    libtcodpy.image_invert(img)
    libtcodpy.image_hflip(img)
    libtcodpy.image_rotate90(img)
    libtcodpy.image_vflip(img)
    libtcodpy.image_scale(img, 24, 24)
    libtcodpy.image_set_key_color(img, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_get_alpha(img, 0, 0)
    libtcodpy.image_is_pixel_transparent(img, 0, 0)
    libtcodpy.image_get_size(img)
    libtcodpy.image_get_pixel(img, 0, 0)
    libtcodpy.image_get_mipmap_pixel(img, 0, 0, 1, 1)
    libtcodpy.image_put_pixel(img, 0, 0, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_blit(img, console, 0, 0, libtcodpy.BKGND_SET, 1, 1, 0)
    libtcodpy.image_blit_rect(img, console, 0, 0, 16, 16, libtcodpy.BKGND_SET)
    libtcodpy.image_blit_2x(img, console, 0, 0)
    libtcodpy.image_save(img, tmpdir.join('test.png').strpath)
    libtcodpy.image_delete(img)

    img = libtcodpy.image_from_console(console)
    libtcodpy.image_refresh_console(img, console)
    libtcodpy.image_delete(img)

    libtcodpy.image_delete(libtcodpy.image_load('libtcod/data/img/circle.png'))
def character_portrait(target):
    portrait_image = libtcod.image_load('green.png')
    libtcod.image_blit_rect(
        portrait_image, 0,
        game_constants.screen_width - game_constants.character_portrait_width,
        game_constants.panel_y, game_constants.character_portrait_width,
        game_constants.panel_height, libtcod.BKGND_SET)
예제 #4
0
def draw_picture(con, image, width):
    picture = libtcod.console.Console(game_constants.portrait_width,
                                      game_constants.portrait_height)
    libtcod.image_blit_rect(image, picture, 0, 0, -1, -1, libtcod.BKGND_NONE)
    libtcod.console_blit(picture, 0, 0, game_constants.portrait_width,
                         game_constants.portrait_height, con, x, y, 1.0, 0.7)
예제 #5
0
def render_all(mapToUse, con):
    global color_light_wall
    global color_light_ground

    # for y in range(GAME_HEIGHT):
    #     for x in range(GAME_WIDTH):
    #         tcod.console_put_char(con, x, y, " ", tcod.BKGND_NONE)

    for y in range(GAME_HEIGHT):
        for x in range(GAME_WIDTH):
            if (mapToUse.map[x][y].charToken != ""):
                # newCharCode = 7
                img = None
                # print(mapToUse.map[x][y].charToken)
                if (mapToUse.map[x][y].charToken == "S"):
                    # newCharCode += 1
                    img = tcod.image_load("LargeWallS.png")
                if (mapToUse.map[x][y].charToken == "N"):
                    # newCharCode += 2
                    img = tcod.image_load("LargeWallN.png")
                if (mapToUse.map[x][y].charToken == "E"):
                    # newCharCode += 3
                    img = tcod.image_load("largeWallE.png")
                if (mapToUse.map[x][y].charToken == "W"):
                    # newCharCode += 4
                    img = tcod.image_load("largeWallW.png")
                if (mapToUse.map[x][y].charToken == "<"):
                    # newCharCode += 5
                    img = tcod.image_load("LargeSW.png")
                if (mapToUse.map[x][y].charToken == ">"):
                    # newCharCode += 6
                    img = tcod.image_load("LargeSE.png")
                if (mapToUse.map[x][y].charToken == "/"):
                    # newCharCode += 7
                    img = tcod.image_load("LargeNW.png")
                if (mapToUse.map[x][y].charToken == "\\"):
                    # newCharCode += 8
                    img = tcod.image_load("LargeNE.png")
                if (mapToUse.map[x][y].charToken == "."):
                    # newCharCode += 9
                    img = tcod.image_load("LargeFloor.png")
                if (mapToUse.map[x][y].charToken == "w"):
                    # newCharCode += 10
                    img = tcod.image_load("DoorW.png")
                if (mapToUse.map[x][y].charToken == "s"):
                    # newCharCode += 11
                    img = tcod.image_load("DoorS.png")
                if (mapToUse.map[x][y].charToken == "n"):
                    # newCharCode += 12
                    img = tcod.image_load("DoorN.png")
                if (mapToUse.map[x][y].charToken == "e"):
                    # newCharCode += 13
                    img = tcod.image_load("DoorE.png")
                # tcod.console_put_char_ex(con, x, y, newCharCode, tcod.white, tcod.black)
                tcod.image_blit_rect(img, con, x, y, 64, 64, tcod.BKGND_NONE)
                # else:
                #      tcod.console_put_char(con, x, y, "#", tcod.BKGND_NONE)
    for roomIndex in mapToUse.roomList:
        # print("room " + roomIndex.roomName + " player list:")
        # print(roomIndex.playerList)
        # print()
        placeX = roomIndex.x1
        placeY = roomIndex.y1
        for i in range(0, len(roomIndex.playerList)):
            # newCharCode = -1
            img = None
            if (roomIndex.playerList[i].playerNum == "0"):
                print("got here")
                img = tcod.image_load("isaiah.png")
                # newCharCode += 1
            if (roomIndex.playerList[i].playerNum == "1"):
                # newCharCode += 3
                img = tcod.image_load("dave.png")
            if (roomIndex.playerList[i].playerNum == "2"):
                # newCharCode += 4
                img = tcod.image_load("ian.png")
            if (roomIndex.playerList[i].playerNum == "3"):
                # newCharCode += 5
                img = tcod.image_load("richard.png")
            if (roomIndex.playerList[i].playerNum == "4"):
                # newCharCode += 6
                img = tcod.image_load("josh.png")
            if (roomIndex.playerList[i].playerNum == "5"):
                # newCharCode += 7
                img = tcod.image_load("dylan.png")
            if (roomIndex.playerList[i].playerNum == "6"):
                # newCharCode += 8
                img = tcod.image_load("will.png")
            # print(roomIndex.playerList[i].playerNum)
            # print(roomIndex.playerList[i].name[0])
            # print(placeX+1, placeY+1)
            # tcod.console_put_char_ex(con, placeX+1, placeY+1, newCharCode, tcod.white, tcod.black)
            tcod.image_blit_rect(img, con, placeX, placeY, 64, 64,
                                 tcod.BKGND_SET)
            if (placeX < roomIndex.x2 - 2):
                placeX += 1
            else:
                placeX = roomIndex.x1
                if (placeY < roomIndex.y2 - 1):
                    placeY += 1
                else:
                    placeY = roomIndex.y1

    # blit the contents of "con" to the root console
    tcod.console_blit(con, 0, 0, GAME_WIDTH, GAME_HEIGHT, 0, 0, 0)