Example #1
0
def handle_events():
    events = get_events()
    for event in events:
        if event.type == SDL_QUIT:
            game_framework.quit()
        else:
            if (event.type, event.key) == (SDL_KEYDOWN, SDLK_SPACE):
                game_framework.change_state(title_state)
Example #2
0
def handle_events():
    events = get_events()
    for event in events:
        if event.type == SDL_QUIT:
            game_framework.quit()
        else:
            if (event.type, event.key) == (SDL_KEYDOWN, SDLK_p):
                game_framework.pop_state()
            if (event.type, event.key) == (SDL_KEYDOWN, SDLK_r):
                game_framework.stack[-2].exit()
                game_framework.change_state(title_state)
Example #3
0
def handle_events():
    global bubble, speed_item_count, dragon
    events = get_events()
    for event in events:
        if event.type == SDL_QUIT:
            game_framework.quit()
        elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE:
            game_framework.quit()
        elif event.type == SDL_KEYDOWN and event.key == SDLK_p:
            dragon.is_move = False
            game_framework.push_state(pause_state)
        else:
            dragon.handle_event(event)
            if event.type == SDL_KEYDOWN and event.key == SDLK_LCTRL:
                dragon.check_attack_delay_end_time = get_time() - dragon.check_attack_delay_start_time
                if dragon.check_attack_delay_end_time > (0.3 - speed_item_count*0.1):
                    dragon.sound_attack()
                    bubble = Bubble(dragon.x, dragon.y, dragon.dir)
                    game_world.add_object(bubble, 4)
                    dragon.check_attack_delay_end_time = 0
                    dragon.check_attack_delay_start_time = get_time()
Example #4
0
def handle_events():
    global choose_button, item_count, is_click, speed_item_count, buy_sound, door, no_money
    events = get_events()
    for event in events:
        if event.type == SDL_QUIT:
            game_framework.quit()
        else:
            if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
                game_framework.quit()

            if (event.type, event.key) == (SDL_KEYDOWN, SDLK_LEFT):
                if choose_button > 1:
                    choose_button -= 1

            elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_RIGHT):
                if choose_button < 3:
                    choose_button += 1

            if (event.type, event.key) == (SDL_KEYDOWN, SDLK_SPACE):
                if choose_button == 1:
                    if first_main_state.dragon.gold >= 500:
                        buy_sound.play()
                        item_count += 1
                        is_click = True
                        second_main_state.dragon.life += 1
                    else:
                        no_money.play()
                elif choose_button == 2:
                    if first_main_state.dragon.gold >= 500:
                        buy_sound.play()
                        item_count += 1
                        speed_item_count += 1
                        is_click = True
                    else:
                        no_money.play()
                else:
                    door.play()
                    game_framework.change_state(third_main_state)