Exemple #1
0
def pause_menu(data):		
    events = EventHandler()
    btnGroup = create_btnGroup()

    def resume_game():
        data['in_start_menu'] = False    
        data['in_game'] = True
        data['in_pause_menu'] = False

    def new_game():
        data['game'] = None
        resume_game()

    def quit():
        data['in_start_menu'] = False    
        data['in_game'] = False    
        data['in_pause_menu'] = False

    def go_to_main():
        data['game'] = None
        data['in_start_menu'] = True
        data['in_game'] = False    
        data['in_pause_menu'] = False

    btnGroup.add_button('resume', resume_game)
    btnGroup.add_button('new game', new_game)
    btnGroup.add_button('quit to menu', go_to_main)
    btnGroup.add_button('quit to desktop', quit)

    events.assign_mouseup(1, btnGroup.event_callback)
    events.assign_keyup(pygame.K_ESCAPE, resume_game)
    events.assign_keyup(pygame.K_q, quit)

    menu_loop(data, btnGroup, events, 'in_pause_menu')
    print("leaving pause menu..")
Exemple #2
0
 def __init__(self, fps=50):
     events = EventHandler()
     events.assign_keyup(pygame.K_p, self.pause)
     events.assign_keyup(pygame.K_q, self.quit)
     events.assign_keyup(pygame.K_f, self.toggle_focus)
     events.assign_keyup(pygame.K_s, self.toggle_shake)
     self.events = events
     self.fps = fps
     self.focused = False
Exemple #3
0
def start_menu(data):		
    
    events = EventHandler()
    btnGroup = create_btnGroup()
    def start_game():
        data['in_start_menu'] = False    
        data['in_game'] = True
        data['in_pause_menu'] = False

    def quit():
        data['in_start_menu'] = False    
        data['in_game'] = False    
        data['in_pause_menu'] = False
        print("Quitting...")

    btnGroup.add_button('start', start_game)
    btnGroup.add_button('quit', quit)
    events.assign_mouseup(1, btnGroup.event_callback)
    events.assign_keyup(pygame.K_q, quit)
    menu_loop(data, btnGroup, events, 'in_start_menu')
    print("leaving main menu..")