Example #1
0
def move_combination (move_list, final_position):
    global gameDisplay, controls, pieces
    for src, dest in move_list:
        create_movement (pieces[src],
                         [square_coordinate[src], square_coordinate[dest]],
                         1, 1, max_velocity)
    taking = final_position in pieces
    if taking:
        remove_piece (final_position)
    while not movement_finished ():
        gameDisplay = blank_board (gameDisplay)
        if taking:
            # taking move
            pass
            # blank_square (gameDisplay, touchgui.unitY (square_size), final_position)
        update_movement ()
        is_finished = False
        forms = all_pieces () + buttons ()
        touchgui.select (forms, event_test, finished, 10)
    #
    #  now update the data structures
    #
    for src, dest in move_list:
        pieces[dest] = pieces[src]
        del pieces[src]
Example #2
0
def main():
    pygame.init()
    if full_screen:
        gameDisplay = pygame.display.set_mode((display_width, display_height),
                                              FULLSCREEN)
    else:
        gameDisplay = pygame.display.set_mode((display_width, display_height))

    pygame.display.set_caption("Simple Test")
    touchgui.set_display(gameDisplay, display_width, display_height)

    forms = button() + glyph()
    gameDisplay.fill(touchguipalate.black)
    touchgui.select(forms, event_test)
Example #3
0
def main ():
    global gameDisplay, controls, shell, is_finished, move_src_square, move_dest_square

    filename = process_options ()
    shell = chessShell.shell (filename)
    board = shell.get_board ()
    pygame.init ()
    if full_screen:
        gameDisplay = pygame.display.set_mode ((display_width, display_height), FULLSCREEN)
    else:
        gameDisplay = pygame.display.set_mode ((display_width, display_height))

    pygame.display.set_caption ("Chess")
    touchgui.set_display (gameDisplay, display_width, display_height)

    gameDisplay.fill (touchguipalate.black)
    gameDisplay = blank_board (gameDisplay)
    createBoard (square_size, board)
    legal_moves = shell.get_legal_moves ()
    forms = freeze_unlisted (all_pieces (), legal_moves) + buttons ()
    player_turn = player_white
    while True:
        is_finished = False
        touchgui.select (forms, event_test, finished)
        if move_src_square is None:
            print ("move_src_square is None")
            forms = freeze_unlisted (all_pieces (), legal_moves) +  buttons ()
        elif move_dest_square is None:
            print ("move_dest_square is None")
            dest_keys = get_dest_squares (move_src_square, legal_moves)
            gameDisplay, dest = highlight_dest_squares (gameDisplay, dest_keys)
            forms = dest + freeze_unlisted (all_pieces (), legal_moves) +  buttons ()
            pieces[move_src_square].set_frozen ()       #  and freeze the chosen piece
        else:
            print ("reached completed move")
            # perform the move
            print ("values =", move_src_square, move_dest_square)
            human_move (legal_moves, move_src_square, move_dest_square)
            move_src_square = None
            move_dest_square = None
            gameDisplay = blank_board (gameDisplay)  # redraw the board to remove highlighted squares
            player_turn = 1 - player_turn
            if player[player_turn] == "computer":
                legal_moves = shell.get_legal_moves ()
                forms = freeze_unlisted (all_pieces (), legal_moves) +  buttons ()
                computer_make_move (legal_moves)
                player_turn = 1 - player_turn
            legal_moves = shell.get_legal_moves ()
            forms = freeze_unlisted (all_pieces (), legal_moves) +  buttons ()
Example #4
0
def main ():
    global players

    pygame.init ()
    if full_screen:
        gameDisplay = pygame.display.set_mode ((display_width, display_height), FULLSCREEN)
    else:
        gameDisplay = pygame.display.set_mode ((display_width, display_height))

    touchgui.set_display (gameDisplay, display_width, display_height)

    forms = buttons () + more_buttons ()
    print(len (forms))
    gameDisplay.fill (touchguipalate.black)
    touchgui.select (forms, event_test)
Example #5
0
def fade_king (move, status):
    global movement_pieces, pieces, static_pieces, gameDisplay
    if status != "continue":
        print ("ending with", status)
        position, symbol = find_king (status)
        print ("position", position, symbol)
        if position != None:
            pieces[position].set_images (chess_red (symbol))
            movement_pieces += [fade (pieces[position], 255, 0, -1)]
            #
            #  now update the data structures
            #
            movement_pieces += [fade (pieces[position], 0, 255, 1, 256)]
            movement_pieces += [fade (pieces[position], 255, 0, -1, 512)]
            # pieces[position] = red
            del pieces[position]
        if move is None:
            while not movement_finished ():
                gameDisplay = blank_board (gameDisplay)
                update_movement ()
                is_finished = False
                forms = all_pieces () + controls
                touchgui.select (forms, event_test, finished, 10)
Example #6
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()