Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
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