Exemple #1
0
def setup():
    '''Setup the frame and event handlers'''
    global frame, next_container, score_label, lines_label, high_score_label, images

    frame = simplegui.Frame('Tetris', (WIDTH, HEIGHT),
                            160,
                            soundtrack=SOUNDTRACK_FILE)
    frame.set_draw_handler(draw)
    frame.set_key_down_handler(key_down)
    frame.set_key_up_handler(key_up)

    if IMAGES_ON:
        images = dict([(key, simplegui.Image(image_info))
                       for key, image_info in image_infos.iteritems()])
    else:
        images = dict([(key, None)
                       for key, image_info in image_infos.iteritems()])

    #Build the control panel
    frame.add_label('')
    frame.add_label('')
    next_container = frame.control_panel.add_sprite_container(
        new_tetroid(), size=(3 * BLOCK_H, 3 * BLOCK_H))
    score_label = frame.add_label('Score: 0')
    lines_label = frame.add_label('Lines: 0')
    frame.add_label('')
    high_score_label = frame.add_label('High Score: ' + str(high_score))

    if SCREEN_SHOT_FILE:
        frame.set_screen_shot_file(SCREEN_SHOT_FILE)

    return frame
Exemple #2
0
def setup():
    '''Setup the frame and event handlers'''
    global frame, images

    #build the frame
    frame = simplegui.Frame('Breakout', (WIDTH, HEIGHT),
                            canvas_color=BACKGROUND_COLOR)
    frame.set_draw_handler(draw)
    frame.set_key_down_handler(key_down)
    frame.set_key_up_handler(key_up)

    #configure images
    if IMAGES_ON:
        images = dict([(key, simplegui.Image(image_info))
                       for key, image_info in image_infos.iteritems()])
    else:
        images = dict([(key, None)
                       for key, image_info in image_infos.iteritems()])

    #setup control panel

    if SCREEN_SHOT_FILE:
        frame.set_screen_shot_file(SCREEN_SHOT_FILE)

    return frame
Exemple #3
0
def setup():
    '''Setup the frame and event handlers'''
    global frame, all_cards_image
    global remaining_cards_label, sets_label, score_label, high_score_label, hint_label

    frame = simplegui.Frame('Set', (WIDTH, HEIGHT), CONTROL_W)
    frame.set_draw_handler(draw)
    frame.set_mouse_left_click_handler(mouse_left_click)
    frame.set_key_up_handler(key_up)
    frame.set_background_color("white")

    all_cards_image = simplegui.Image(CARDS_IMAGE_INFO)

    remaining_cards_label = frame.add_label("")
    sets_label = frame.add_label("")
    score_label = frame.add_label("")
    high_score_label = frame.add_label("")
    frame.add_label("")
    hint_label = frame.add_label("")
    frame.add_label("")

    frame.add_button("Hint", hint, BUTTON_W, BUTTON_FONT_H)
    frame.add_button("Show 1", show, BUTTON_W, BUTTON_FONT_H)
    frame.add_button("Deal More", deal_more, BUTTON_W, BUTTON_FONT_H)
    frame.add_button("New Game", new_game, BUTTON_W, BUTTON_FONT_H)
    
    return frame
Exemple #4
0
def setup():
    '''Setup the menu for the games.'''
    global frame, buttons

    frame = simplegui.Frame('Menu', (0, HEIGHT), CONTROL_WIDTH)
    frame.set_key_up_handler(key_up)

    frame.add_label('Menu')

    buttons = []
    buttons.append(
        frame.add_button('Fifteen', fifteen_starter, BUTTON_WIDTH,
                         BUTTON_FONT_SIZE))
    buttons.append(
        frame.add_button('Pong', pong_starter, BUTTON_WIDTH, BUTTON_FONT_SIZE))
    buttons.append(
        frame.add_button('Tetris', tetris_starter, BUTTON_WIDTH,
                         BUTTON_FONT_SIZE))
    buttons.append(
        frame.add_button('Snake', snake_starter, BUTTON_WIDTH,
                         BUTTON_FONT_SIZE))
    buttons.append(
        frame.add_button('Breakout', breakout_starter, BUTTON_WIDTH,
                         BUTTON_FONT_SIZE))
    buttons.append(
        frame.add_button('Cryptoquip', cryptoquip_starter, BUTTON_WIDTH,
                         BUTTON_FONT_SIZE))

    return frame
Exemple #5
0
def setup():
    '''Setup the frame and controls'''
    global frame, images

    frame = simplegui.Frame('Snake', (WIDTH, HEIGHT))

    frame.set_background_color(BACKGROUND_COLOR)
    frame.set_draw_handler(draw)

    frame.set_key_down_handler(key_down)
    frame.set_key_up_handler(key_up)
    frame.set_mouse_left_click_handler(mouse_click)

    #configure images
    if IMAGES_ON:
        images = dict([(key, simplegui.Image(image_info))
                       for key, image_info in image_infos.iteritems()])
    else:
        images = dict([(key, None)
                       for key, image_info in image_infos.iteritems()])

    if SCREEN_SHOT_FILE:
        frame.set_screen_shot_file(SCREEN_SHOT_FILE)

    return frame
def setup():
    '''Sets up a new cryptoquip game'''
    global frame
    frame = simplegui.Frame('Cryptoquip', (WIDTH, HEIGHT),
                            canvas_color=BACKGROUND_COLOR)

    frame.set_draw_handler(draw)
    frame.set_key_down_handler(key_down)
    frame.set_key_up_handler(key_up)
    frame.set_mouse_left_click_handler(mouse_click)

    return frame
Exemple #7
0
def setup():
    '''Setup the frame and event handlers'''
    global frame, images
    frame = simplegui.Frame('World', (WIDTH, HEIGHT))
    frame.set_draw_handler(draw)
    frame.set_key_down_handler(key_down)
    frame.set_key_up_handler(key_up)
    frame.set_mouse_left_click_handler(mouse_click)
    frame.set_mouse_move_handler(mouse_move)

    images = dict([(key, simplegui.Image(image_info))
                   for key, image_info in image_infos.iteritems()])
    return frame
Exemple #8
0
def setup():
    '''Setup the game'''
    global frame
    
    # create frame
    frame = simplegui.Frame('Fifteen',(CANVAS_W, CANVAS_H),BUTTON_W)
    
    # register event handlers
    frame.set_draw_handler(draw)
    frame.add_button("Reset tiles", reset_button, BUTTON_W, BUTTON_FONT_H)
    frame.add_button("Shuffle tiles", shuffle_button, BUTTON_W, BUTTON_FONT_H)
    frame.set_key_up_handler(key_up)
    frame.set_mouse_left_click_handler(click)
    
    return frame
Exemple #9
0
def setup():
    '''Setup the frame and buttons'''
    global frame, plyr1_button, plyr2_button, difficulty_button
    global sound_beeep, sound_peeeeeep, sound_plop
    # create frame
    frame = simplegui.Frame("Pong", (WIDTH, HEIGHT), BUTTON_W)

    # register event handlers
    frame.set_draw_handler(draw)
    frame.set_key_down_handler(keydown)
    frame.set_key_up_handler(keyup)

    frame.add_label(" ")
    frame.add_button("Restart", new_game, 0.9 * BUTTON_W, BUTTON_FONT_H)
    frame.add_button("Pause", pause, 0.9 * BUTTON_W, BUTTON_FONT_H)

    #frame.add_label(" ")
    frame.add_label("Player 1: w up, s down")
    frame.add_label("Player 2: up and down arrows")

    #frame.add_label(" ")
    plyr1_button = frame.add_button("Player 1: Human", plyr1_toggle,
                                    0.9 * BUTTON_W, BUTTON_FONT_H)
    plyr2_button = frame.add_button("Player 2: Human", plyr2_toggle,
                                    0.9 * BUTTON_W, BUTTON_FONT_H)

    #frame.add_label(" ")
    difficulty_button = frame.add_button("Computer: " + difficulty_mode,
                                         change_difficulty, 0.9 * BUTTON_W,
                                         BUTTON_FONT_H)

    #frame.add_label(" ")
    frame.add_button("Mute", mute, 0.9 * BUTTON_W, BUTTON_FONT_H)

    sound_beeep = simplegui.Sound(
        'https://dl.dropboxusercontent.com/u/22969407/sounds_ping_pong_8bit/ping_pong_8bit_beeep.ogg'
    )
    sound_peeeeeep = simplegui.Sound(
        'https://dl.dropboxusercontent.com/u/22969407/sounds_ping_pong_8bit/ping_pong_8bit_peeeeeep.ogg'
    )
    sound_plop = simplegui.Sound(
        'https://dl.dropboxusercontent.com/u/22969407/sounds_ping_pong_8bit/ping_pong_8bit_plop.ogg'
    )

    return frame