示例#1
0
def buttons ():
    return [touchgui.image_tile (button_list ("power"),
                                 touchgui.posX (0.95), touchgui.posY (1.0),
                                 100, 100, myquit),
            touchgui.image_tile (button_list ("return"),
                                 touchgui.posX (0.0), touchgui.posY (1.0),
                                 100, 100, myreturn)]
示例#2
0
def createBoard (size, board_layout):
    global static_pieces, pieces, square_coordinate
    pixels = touchgui.unitY (size)
    makePieces (pixels)
    static_pieces = []
    pieces = {}
    square_coordinate = {}
    for count, p in enumerate (board_layout):
        x = count % 8
        y = int (count / 8)
        key = "%c%c" % (chr (x + ord ('a')), chr ((7-y) + ord ('1')))
        square_coordinate[key] = [(x+1) * pixels, (y+1) * pixels]
        if p == ".":
            if key in pieces:
                del pieces[key]
        elif p.upper () == p:
            tile = touchgui.image_tile (chess_white (p),
                                        (x+1) * pixels, (y+1) * pixels,
                                        pixels, pixels, square_pressed)
            tile.set_background (None)
            static_pieces += [tile]
            pieces[key] = tile
        else:
            tile = touchgui.image_tile (chess_black (p),
                                        (x+1) * pixels, (y+1) * pixels,
                                        pixels, pixels, square_pressed)
            tile.set_background (None)
            pieces[key] = tile
            static_pieces += [tile]
示例#3
0
def button_controls ():
    if player[player_black] == "human":
        black = button_list ("singleplayer")
    else:
        black = button_list ("gear")
    if player[player_white] == "human":
        white = button_list ("singleplayer")
    else:
        white = button_list ("gear")
    return [touchgui.image_tile (white,
                                 touchgui.posX (0.8), touchgui.posY (0.9),
                                 100, 100, fn_white_player),
            touchgui.image_tile (black,
                                 touchgui.posX (0.85), touchgui.posY (0.9),
                                 100, 100, fn_black_player),
            touchgui.image_tile (button_list ("power"),
                                 touchgui.posX (0.95), touchgui.posY (1.0),
                                 100, 100, myquit)]
示例#4
0
def highlight_dest_squares (gameDisplay, keylist):
    gameDisplay = blank_board (gameDisplay)
    pixels = touchgui.unitY (square_size)
    dest = []  #  destination square tiles
    for key in keylist:
        x, y = square_coordinate[key]
        if (ord (key[0]) + ord (key[1])) % 2 == 0:
            dest += [touchgui.image_tile ([touchgui.color_tile (dark_square, pixels, pixels),
                                           touchgui.color_tile (high_dark_square, pixels, pixels),
                                           touchgui.color_tile (bright_dark_square, pixels, pixels),
                                           touchgui.color_tile (dark_square, pixels, pixels)],
                                          x, y, pixels, pixels, dest_selected)]
        else:
            dest += [touchgui.image_tile ([touchgui.color_tile (light_square, pixels, pixels),
                                           touchgui.color_tile (high_light_square, pixels, pixels),
                                           touchgui.color_tile (bright_light_square, pixels, pixels),
                                           touchgui.color_tile (light_square, pixels, pixels)],
                                          x, y, pixels, pixels, dest_selected)]
    return gameDisplay, dest
示例#5
0
def processor_icons ():
    n = multiprocessing.cpu_count ()
    rows, columns = format_grid (n)
    unit = touchgui.unitY (0.1)
    procs = []
    for row in range (rows):
        for column in range (columns):
            procs += [touchgui.image_tile (images_red ("tux"),
                                           touchgui.posX (0.55) + unit * row, touchgui.posY (0.8) + unit * column,
                                           100, 100)]
    return procs
示例#6
0
def more_buttons ():
    size = 75
    limit = -1
    count = 0
    b = []
    for x in range (0, display_width-size, size):
        for y in range (100, display_height-size, size):
            b += [touchgui.image_tile (button_list ("return"),
                                       x, y,
                                       size, size, myreturn)]
            if count == limit:
                return b
            count += 1
    return b
示例#7
0
def main():
    global tabletOrMouse, audio, orig_mouse_pointer, attackOrInteractForm, arrowOrCombatForm, bombButtonForm, nonCombatForm, combatTestForm, playerHealth, playerBombs, playerArrows, signal
    global forest_green, black, dark_blue
    global health, bombs, arrows, health_text, bombcount_text, arrowcount_text
    global bombDebug, arrowDebug, healDebug, damageDebug

    pygame.init()
    gameDisplay = pygame.display.set_mode((display_width, display_height))

    orig_mouse_pointer = pygame.mouse.get_cursor()

    pygame.display.set_caption("Penguin Tower")
    touchgui.set_display(gameDisplay, display_width, display_height)
    isoobject.set_display(gameDisplay, display_width, display_height)

    # tabletOrMouse - Hides/shows the mouse cursor, used when either on PC or a Tablet
    tabletOrMouse = touchgui.image_tile(image_list("mouse"),
                                        touchgui.posX(0.1), touchgui.posY(1.0),
                                        100, 100, flipMouseTablet)

    # audio - Flips audio for the program
    audio = touchgui.image_tile(image_list("audioOn"), touchgui.posX(0.0),
                                touchgui.posY(1.0), 100, 100, flipAudio)

    # signal - displays network signal.
    signal = touchgui.image_tile(image_list("signal1"), touchgui.posX(0.15),
                                 touchgui.posY(1.0), 100, 100, signal_value)

    # attackorInteractForm - Either attack with Sword, or interact button depending on mode
    attackOrInteractForm = touchgui.image_tile(combat_list("slashresize"),
                                               touchgui.posX(0.95),
                                               touchgui.posY(0.1), 100, 100,
                                               interactOrAttack)

    # arrowOrCombatForm - Either shoot an arrow, or switch to combat mode, depending on mode
    arrowOrCombatForm = touchgui.image_tile(combat_list("arrowresize"),
                                            touchgui.posX(0.95),
                                            touchgui.posY(0.3), 100, 100,
                                            arrowOrCombat)

    # bombButtonForm - Either place a grenade, or an invisible button, depending on mode
    bombButtonForm = touchgui.image_tile(combat_list("bombresize"),
                                         touchgui.posX(0.95),
                                         touchgui.posY(0.5), 100, 100,
                                         bombButton)

    # nonCombatForm - Switches to adventure mode, or an invisible button, depending on mode
    nonCombatForm = touchgui.image_tile(image_list("cross"),
                                        touchgui.posX(0.95),
                                        touchgui.posY(0.7), 100, 100,
                                        nonCombatButton)

    # controls - Form for our extra buttons in the top left of the screen, and the power in the top right
    controls = [
        touchgui.form([
            touchgui.image_tile(image_list("power"), touchgui.posX(0.95),
                                touchgui.posY(1.0), 100, 100, myquit), audio,
            touchgui.image_tile(image_list("singleplayer"),
                                touchgui.posX(0.05), touchgui.posY(1.0), 100,
                                100), tabletOrMouse, signal,
            touchgui.image_tile(image_list("singleplayer"),
                                touchgui.posX(0.05), touchgui.posY(1.0), 100,
                                100)
        ])
    ]

    # movement_arrows - Form for our movement buttons on the bottom left of the screen
    movement_arrows = [
        touchgui.form([
            touchgui.image_tile(image_list("arrowUp"), touchgui.posX(0.05),
                                touchgui.posY(0.30), 100, 100),
            touchgui.image_tile(image_list("arrowLeft"), touchgui.posX(0.00),
                                touchgui.posY(0.20), 100, 100, orient_left),
            touchgui.image_tile(image_list("arrowRight"), touchgui.posX(0.10),
                                touchgui.posY(0.20), 100, 100, orient_right),
            touchgui.image_tile(image_list("arrowDown"), touchgui.posX(0.05),
                                touchgui.posY(0.10), 100, 100, orient_back)
        ])
    ]

    # health - Info panel showing off the player's HP
    health = touchgui.text_tile(forest_green, forest_green, forest_green,
                                forest_green, str(playerHealth),
                                touchgui.unitY(0.05), touchgui.posX(0.35),
                                touchgui.posY(0.95), touchgui.unitX(0.045),
                                touchgui.unitY(0.045))

    # health_text - Just a label
    health_text = touchgui.text_tile(black, black, black, black, "Health",
                                     touchgui.unitY(0.05), touchgui.posX(0.34),
                                     touchgui.posY(1.0), touchgui.unitX(0.065),
                                     touchgui.unitY(0.045))

    # bombs - Info panel showing off the player's grenade count
    bombs = touchgui.text_tile(forest_green, forest_green, forest_green,
                               forest_green, str(playerBombs),
                               touchgui.unitY(0.05), touchgui.posX(0.5),
                               touchgui.posY(0.95), touchgui.unitX(0.045),
                               touchgui.unitY(0.045))

    # bombcount_text - Just a Label
    bombcount_text = touchgui.text_tile(black, black, black, black, "Grenades",
                                        touchgui.unitY(0.05),
                                        touchgui.posX(0.475),
                                        touchgui.posY(1.0),
                                        touchgui.unitX(0.095),
                                        touchgui.unitY(0.045))

    # arrows - Info panel showing off the player's arrow count
    arrows = touchgui.text_tile(forest_green, forest_green, forest_green,
                                forest_green, str(playerArrows),
                                touchgui.unitY(0.05), touchgui.posX(0.65),
                                touchgui.posY(0.95), touchgui.unitX(0.045),
                                touchgui.unitY(0.045))

    # arrowcount_text - Just a Label
    arrowcount_text = touchgui.text_tile(black, black, black, black, "Arrows",
                                         touchgui.unitY(0.05),
                                         touchgui.posX(0.64),
                                         touchgui.posY(1.0),
                                         touchgui.unitX(0.07),
                                         touchgui.unitY(0.045))

    # arrowDebug - Debug button that gives the player 10 arrows
    arrowDebug = touchgui.text_tile(dark_blue, dark_blue, blue,
                                    green, "Give 10 Arrows",
                                    touchgui.unitY(0.05), touchgui.posX(0.03),
                                    touchgui.posY(0.75), touchgui.unitX(0.15),
                                    touchgui.unitY(0.045), giveArrows)

    # bombDebug - Debug button that gives the player 10 grenades
    bombDebug = touchgui.text_tile(dark_blue, dark_blue, blue,
                                   green, "Give 10 Grenades",
                                   touchgui.unitY(0.05), touchgui.posX(0.03),
                                   touchgui.posY(0.7), touchgui.unitX(0.17),
                                   touchgui.unitY(0.045), giveBombs)

    # healDebug - Debug button that heals the player back to 100HP
    healDebug = touchgui.text_tile(dark_blue, dark_blue,
                                   blue, green, "Heal to Full",
                                   touchgui.unitY(0.05), touchgui.posX(0.03),
                                   touchgui.posY(0.65), touchgui.unitX(0.15),
                                   touchgui.unitY(0.045), healPlayer)

    # damageDebug - Debug button that hits the player for 10HP
    damageDebug = touchgui.text_tile(dark_blue, dark_blue,
                                     blue, green, "10 Damage",
                                     touchgui.unitY(0.05), touchgui.posX(0.03),
                                     touchgui.posY(0.6), touchgui.unitX(0.15),
                                     touchgui.unitY(0.045), damagePlayer)

    # health_and_info - Form that merges the HP, Arrow and Grenade info panels and Labels
    health_and_info = [
        touchgui.form([
            health, health_text, bombs, bombcount_text, arrows, arrowcount_text
        ])
    ]

    # interaction_buttons - Form that merges the 4 interaction buttons in the bottom right
    interaction_buttons = [
        touchgui.form([
            attackOrInteractForm, arrowOrCombatForm, bombButtonForm,
            nonCombatForm
        ])
    ]

    # debug_menu - Form that merges the debug buttons together
    debug_menu = [
        touchgui.form([arrowDebug, bombDebug, healDebug, damageDebug])
    ]

    forms = controls + movement_arrows + interaction_buttons + health_and_info + debug_menu
    isoobject.testRoom()  #Renders a basic 3D room for us
    touchgui.select(forms, myquit)
    freezeButtons()
    pygame.display.update()