def select(musicName): if targetScene == 'play': play_state.playMusicName = musicName gfw.push(play_state) else: record_state.recordMusicName = musicName gfw.push(record_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_x: wav_select.play() gfw.push(select_state)
def animalshpstatchange(): global whostate, main_ui animalshop_state.inven = player.inven animalshop_state.money = main_ui.money animalshop_state.animals = animals whostate = ANIMALSHOP_STATE gfw.push(animalshop_state)
def end_game(): global state, START, CHECK state = STATE_GAME_OVER CHECK = False gfw.push(restart) music_bg.stop()
def handle_event(self, e): global answer, ask, p_key, me_shout_time, me_shout_randidx, frame, answer_time if e.type == SDL_KEYDOWN: if e.key == SDLK_q and frame != 1600: #프레임이 1600일때는 키보드 입력 안됨 p_key = 1 me_shout_randidx = random.randint(0, 2) self.Correct_Check() me_shout_time = get_time() elif e.key == SDLK_w and frame != 1600: #프레임이 1600일때는 키보드 입력 안됨 p_key = 2 me_shout_randidx = random.randint(0, 2) self.Correct_Check() me_shout_time = get_time() elif e.key == SDLK_e and frame != 1600: #프레임이 1600일때는 키보드 입력 안됨 p_key = 3 me_shout_randidx = random.randint(0, 2) self.Correct_Check() me_shout_time = get_time() elif e.key == SDLK_r and frame != 1600: #프레임이 1600일때는 키보드 입력 안됨 p_key = 4 me_shout_randidx = random.randint(0, 2) self.Correct_Check() me_shout_time = get_time() elif e.key == SDLK_RETURN: self.health -= 10 gfw.push(game_state, 2, self.health) if ask == True: answer = True if ask_ == True: answer_time = get_time() elif e.key == SDLK_SPACE: gfw.change(game_state, 2, self.health)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_x: wav_entermain.play() gfw.push(main_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): gfw.push(game_state)
def start(theme): #global bg_music #bg_music.stop() #del bg_music gfw.world.remove(highscore) horz_state.theme = theme gfw.push(horz_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif(e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif(e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): music_bg.stop() gfw.push(main_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_RETURN): music.stop() gfw.push(game_state, 1, 100)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif e.type == SDL_KEYDOWN: music_title.stop() gfw.push(game_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key in [SDLK_ESCAPE, SDLK_q]: gfw.quit() elif e.key in [SDLK_RETURN, SDLK_KP_ENTER]: gfw.push(main)
def start(theme): pair_state.theme = theme world2.theme = theme if button.playtype == 1: gfw.push(pair_state) elif button.playtype == 2: gfw.push(world2)
def handle_event(e): global player if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.push(option_state) player.handle_event(e) UC.handle_event(e)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): global titlemusic titlemusic.set_volume(0) gfw.push(game_state)
def draw(): gfw.world.draw() if state == STATE_GAME_OVER: game_over_image.draw(get_canvas_width() // 2, get_canvas_height() // 2) gfw.push(howtostage2) if state == STATE_CLEAR: clear.draw(get_canvas_width() // 2, get_canvas_height() // 2)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): pass elif e.key == SDLK_RETURN: # 엔터 게임시작 gfw.push(main_state2)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.pop() elif e.key == SDLK_p: gfw.push(pause_state) boy.handle_event(e)
def handle_event(e): # prev_dx = boy.dx if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.push(menu_state) p.handle_event(e)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.pop() elif e.key == SDLK_RETURN: #엔터 게임시작 start_game() elif e.key == SDLK_SPACE: #스페이스바 다음스테이지 gfw.push(howtostage2) player.handle_event(e)
def handle_mouse(e): global mx , my if e.type == SDL_MOUSEMOTION: mx = e.x my = get_canvas_height() - 1 - e.y if e.type == SDL_MOUSEBUTTONDOWN: if mx > 60 and mx < 140 and my>50 and my<150: gfw.push(title_state) if mx > 1560 and mx < 1640 and my>40 and my<160: gfw.push(main_state)
def update(): global isPaused global stage global timer if isPaused: return gfw.world.update() if player.get_goal() and stage < 12: gfw.world.cleartime_add(stage, timer.get_time()) gfw.push(result_state) elif player.get_goal() and stage == 12: gfw.world.cleartime_add(stage, timer.get_time()) gfw.change(ending_state)
def handle_event(e): global help_ if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.quit() elif e.key == SDLK_SPACE: if help_ is False: gfw.push(main_state) elif e.key == SDLK_h: button_wav.play() if help_ is False: help_ = True elif help_ is True: help_ = False
def change_cookie(n): if gfw.world.count_at(gfw.layer.stand) > 0: for obj in gfw.world.objects_at(gfw.layer.stand): gfw.world.remove(obj) stand = ReadyPlayer(n,lambda: gfw.push(playerchoose_state)) gfw.world.add(gfw.layer.stand, stand)
def handle_mouse(e): global main_sound, capture, title if e.type == SDL_MOUSEMOTION: pos = gobj.mouse_xy(e) if not capture: if pos[1] <= canvas_height * 0.87 + 50 and pos[ 1] >= canvas_height * 0.87 - 50: main_sound.play() for obj in gfw.world.objects_at(gfw.layer.title): obj.image = gfw.image.load(gobj.res('음악선택이미지클릭.png')) capture = True return False if capture: if pos[1] > canvas_height * 0.87 + 50 or pos[ 1] < canvas_height * 0.87 - 50: main_sound.stop() for obj in gfw.world.objects_at(gfw.layer.title): obj.image = gfw.image.load(gobj.res('음악선택이미지.png')) capture = False return False if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT: pos = gobj.mouse_xy(e) if pos[1] <= canvas_height * 0.87 and pos[ 1] >= canvas_height * 0.87 - 50 and pos[ 0] > canvas_width // 2 and pos[0] < canvas_width * 0.9: main_sound.stop() del main_sound return gfw.push(main_state) return False
def handle_event(e): global select, menu_pointer if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.quit() elif e.key == SDLK_UP: if select == 'exit': change_selection.play() select = 'start' menu_pointer.pos = (canvas_width // 2, canvas_height // 4) elif e.key == SDLK_DOWN: if select == 'start': change_selection.play() select = 'exit' menu_pointer.pos = (canvas_width // 2, canvas_height // 6 + 17) elif e.key == SDLK_RETURN: button_confirm.play() if select == 'start': gfw.push(loading_state) elif select == 'exit': gfw.quit() elif e.type == SDL_MOUSEMOTION: if get_canvas_height() - e.y - 1 >= canvas_height // 4 - 10: if select == 'exit': change_selection.play() select = 'start' menu_pointer.pos = (canvas_width // 2, canvas_height // 4) else: if select == 'start': change_selection.play() select = 'exit' menu_pointer.pos = (canvas_width // 2, canvas_height // 6 + 17) elif e.type == SDL_MOUSEBUTTONDOWN: x = canvas_width // 2 y1 = canvas_height // 4 y2 = canvas_height // 6 + 17 if abs(e.x - x) <= 80: if abs(get_canvas_height() - e.y - 1 - y1) <= 10: button_confirm.play() select = 'start' gfw.push(loading_state) elif abs(get_canvas_height() - e.y - 1 - y2) <= 10: button_confirm.play() select = 'exit' gfw.quit()
def handle_event(e): global image, state if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): gfw.push(game_state) if e.type == SDL_MOUSEMOTION: if e.x >= 420 and e.x <= 700 and e.y >= 92 and e.y <= 201: image = gfw.image.load('../res/background/menu_state_1.png') state = STATE_ON else: image = gfw.image.load('../res/background/menu_state_0.png') state = STATE_OFF if e.type == SDL_MOUSEBUTTONDOWN: if state == STATE_ON: gfw.change(game_state)
def handle_event(e): global main_sound if e.type == SDL_QUIT: return gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_RETURN: main_sound.stop() del main_sound return gfw.push(main_state) handle_mouse(e)
def handle_event(e): global selecty,selected if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_DOWN: if selecty - 70 >30 : selecty -= 70 selected -= 1 elif e.key == SDLK_UP: if selecty + 70 <=240: selecty += 70 selected += 1 elif e.key == SDLK_RETURN: if selected == 3: gfw.push(main_state) elif selected == 2: gfw.push(rank_state) elif selected == 1: gfw.quit()
def handle_event(e): global soldier, princess, ret, menu_music event = (e.type, e.key) if e.type == SDL_QUIT: gfw.quit() elif event == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.pop() elif event == (SDL_KEYDOWN, SDLK_LEFT): menu_music.play() ret = 1 soldier.set_animation(True) princess.set_animation(False) elif event == (SDL_KEYDOWN, SDLK_RIGHT): menu_music.play() ret = 2 soldier.set_animation(False) princess.set_animation(True) elif event == (SDL_KEYDOWN, SDLK_RETURN): gfw.push(game_state, ret)