def check_events(): event = game.event.poll() if event.type == game.KEYUP: key_pressed = event.key if (key_pressed == K_ESCAPE): go_back() elif (key_pressed == K_SPACE or key_pressed == K_RETURN): #moving to the next "slide" global cur_text_time cur_text_time = -1.0 elif event.type == game.MOUSEMOTION: x, y = event.pos if (back_rect.collidepoint(x, y)): highlight_back(True) else: highlight_back(False) elif event.type == game.MOUSEBUTTONUP: x, y = event.pos if (back_rect.collidepoint(x, y)): go_back() elif (data.sound_image_rect.collidepoint(x, y)): data.mute_music(not data.music_muted) else: #moving to the next "slide" cur_text_time = -1.0 elif event.type == game.QUIT: data.terminate(0)
def check_events(): """ Elegxos event etsi wste na ginontai dektes energoies opws click, [Enter] klp ta opoia 9a proxwrhsoun sto epomeno keimeno xwris na xreiazetai o xrhsths na perimenei na teleiwsei o kanonikos xronos pou apaiteitai gia thn allagh mias diafaneias. """ event = game.event.poll() global cur_text_time if event.type == game.KEYUP: key_pressed = event.key if (key_pressed == K_ESCAPE): go_back() elif (key_pressed == K_SPACE or key_pressed == K_RETURN): #moving to the next "slide" cur_text_time = -1.0 elif event.type == game.MOUSEMOTION: x, y = event.pos if (back_rect.collidepoint(x, y)): highlight_back(True) else: highlight_back(False) elif event.type == game.MOUSEBUTTONUP: x, y = event.pos if (back_rect.collidepoint(x, y)): go_back() elif (data.sound_image_rect.collidepoint(x, y)): data.mute_music(not data.music_muted) else: #moving to the next "slide" cur_text_time = -1.0 elif event.type == game.QUIT: data.terminate(0)
def check_events(): event = game.event.poll() if event.type == game.KEYUP: key_pressed = event.key if (key_pressed == K_ESCAPE): go_back() elif event.type == game.MOUSEMOTION: x, y = event.pos if (back_rect.collidepoint(x, y)): highlight_back(True) else: highlight_back(False) elif event.type == game.MOUSEBUTTONUP: global level_1_rect, level_2_rect, level_3_rect, level_4_rect x, y = event.pos if (level_1_rect.collidepoint(x, y)): load_level_1() elif (level_2_rect.collidepoint(x, y)): load_level_2() elif (level_3_rect.collidepoint(x, y)): load_level_3() elif (level_4_rect.collidepoint(x, y)): load_level_4() elif (back_rect.collidepoint(x, y)): go_back() elif (data.sound_image_rect.collidepoint(x, y)): data.mute_music(not data.music_muted) elif event.type == game.QUIT: data.terminate(0)
def check_events(): """ Elegxos twn event, pou einai o kersoras, ti koumpia pataei o xrhsths klp """ global CURRENT_MENU_SELECTION event = game.event.poll() if event.type == game.MOUSEMOTION: x, y = event.pos if (select_level_rect.collidepoint(x, y)): CURRENT_MENU_SELECTION = 1 elif (help_rect.collidepoint(x, y)): CURRENT_MENU_SELECTION = 2 elif (credits_rect.collidepoint(x, y)): CURRENT_MENU_SELECTION = 3 elif (quit_rect.collidepoint(x, y)): CURRENT_MENU_SELECTION = 4 highlight_option(CURRENT_MENU_SELECTION) elif event.type == game.MOUSEBUTTONUP: x, y = event.pos if (select_level_rect.collidepoint(x, y)): launch_option(1) elif (help_rect.collidepoint(x, y)): launch_option(2) elif (credits_rect.collidepoint(x, y)): launch_option(3) elif (quit_rect.collidepoint(x, y)): launch_option(4) elif (data.sound_image_rect.collidepoint(x, y)): data.mute_music(not data.music_muted) elif event.type == game.KEYUP: key_pressed = event.key if (key_pressed == K_RETURN or key_pressed == K_SPACE): launch_option(CURRENT_MENU_SELECTION) elif (key_pressed == K_ESCAPE): data.terminate(0) else: if (key_pressed == K_UP): CURRENT_MENU_SELECTION -= 1 elif (key_pressed == K_DOWN): CURRENT_MENU_SELECTION += 1 if (CURRENT_MENU_SELECTION > 4): CURRENT_MENU_SELECTION = 1 elif (CURRENT_MENU_SELECTION < 1): CURRENT_MENU_SELECTION = 4 highlight_option(CURRENT_MENU_SELECTION) elif event.type == game.QUIT: data.terminate(0)
def check_events(): event = game.event.poll() if event.type == game.KEYUP: key_pressed = event.key if (key_pressed == K_SPACE or key_pressed == K_RETURN or key_pressed == K_LCTRL): hero_jump() elif (key_pressed == K_ESCAPE): data.game_paused = True elif event.type == game.MOUSEBUTTONUP: x, y = event.pos if (data.sound_image_rect.collidepoint(x, y)): data.mute_music(not data.music_muted) else: hero_jump() elif event.type == game.QUIT: data.terminate(0) global cat_hero if (game.sprite.spritecollide(cat_hero, data.points, True)): add_score() data.points_sound.play() elif (game.sprite.spritecollide(cat_hero, data.barriers, False)): data.slam_sound.play() data.lose_sound.play() action_now = data.show_loser_options(1, cat_hero) if (action_now == 1): #restart to level start() else: data.LEVEL_1_EXIT = True menu_libs.level_selection.show() elif (game.sprite.spritecollide(cat_hero, data.finish_line, False)): #level complete! data.win_sound.play() data.level_now = 4 data.LEVEL_3_EXIT = True menu_libs.level_selection.show()