def handle_events(): events = pico2d.get_events() for event in events: if event.type == pico2d.SDL_QUIT: Game_FrameWork.quit() elif event.type == pico2d.SDL_KEYDOWN and event.key == pico2d.SDLK_ESCAPE: Game_FrameWork.quit()
def handle_events(): 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() else: player.handle_event(event)
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_ESCAPE): Game_FrameWork.quit() elif ( event.type, event.key ) == (SDL_KEYDOWN, SDLK_SPACE): Game_FrameWork.change_state(Stage1_State)
def handle_events(): global player, UI, lizardMpValue, gemumuMpValue, magicianMpValue, lizardList, lizardButton, lizardCount global gemumuList, magicianList, magicianButton, gemumuButton, gemumuCount, magicianCount, storeSound events = get_events() for event in events: if event.type == SDL_QUIT: Game_FrameWork.quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): Game_FrameWork.change_state(Title_State) elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_i): storeSound.play() if(ui.storeCheck == False): ui.storeCheck = True else: ui.storeCheck = False elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_1): if(player.mp - lizardMpValue > 0 and ui.storeCheck == False): lizardList.append(Lizard(player.x)) lizardCount += 1 player.mp -= lizardMpValue elif(ui.storeCheck == True and ui.money > 100 ): ui.money -= 100 for lizard in lizardList: lizard.maxHp += 100 lizard.hp = lizard.maxHp elif (event.type, event.key) == (SDL_KEYUP, SDLK_2): if(player.mp - gemumuMpValue > 0 and ui.storeCheck == False): gemumuList.append(Gemumu(player.x)) gemumuCount += 1 player.mp -= gemumuMpValue elif(ui.storeCheck == True and ui.money > 200 ): ui.money -= 200 for gemumu in gemumuList: gemumu.maxHp += 100 gemumu.hp = gemumu.maxHp elif (event.type, event.key) == (SDL_KEYUP, SDLK_3): if(player.mp - magicianMpValue > 0 and ui.storeCheck == False): magicianList.append(Magician(player.x)) magicianCount += 1 player.mp -= magicianMpValue elif(ui.storeCheck == True and ui.money > 400 ): ui.money -= 400 for magician in magicianList: magician.maxHp += 100 magician.hp = magician.maxHp elif (event.type, event.key) == (SDL_KEYUP, SDLK_4): if(ui.storeCheck == True and ui.money > 100 ): ui.money -= 100 for lizard in lizardList: lizard.att += 50 elif (event.type, event.key) == (SDL_KEYUP, SDLK_5): if(ui.storeCheck == True and ui.money > 200 ): ui.money -= 200 for gemumu in gemumuList: gemumu.att += 50 elif (event.type, event.key) == (SDL_KEYUP, SDLK_6): if(ui.storeCheck == True and ui.money > 300 ): ui.money -= 300 for magician in magicianList: magician.att += 50 elif (event.type) == SDL_MOUSEMOTION: if(87 <= event.x and event.x <= 113 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - lizardMpValue > 0): ui.LizardFrame = 27 else: ui.LizardFrame = 54 elif(117 <= event.x and event.x <= 143 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - gemumuMpValue > 0): ui.GemumuFrame = 27 else: ui.GemumuFrame = 54 elif(147 <= event.x and event.x <= 173 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - magicianMpValue > 0): ui.MagicianFrame = 27 else: ui.MagicianFrame = 54 else: ui.LizardFrame = 0 ui.GemumuFrame = 0 ui.MagicianFrame = 0 #UI 위에 마우스를 올려놓은상태에서 왼쪽 버튼을 DOWN 했을경우 elif (event.type, event.button) == (SDL_MOUSEBUTTONDOWN, SDL_BUTTON_LEFT): if(87 <= event.x and event.x <= 113 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - lizardMpValue > 0): lizardButton = True else: ui.LizardFrame = 54 elif(117 <= event.x and event.x <= 143 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - gemumuMpValue > 0): gemumuButton = True else: ui.GemumuFrame = 54 elif(147 <= event.x and event.x <= 173 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - magicianMpValue > 0): magicianButton = True else: ui.MagicianFrame = 54 elif (event.type, event.button) == (SDL_MOUSEBUTTONUP, SDL_BUTTON_LEFT): if(87 <= event.x and event.x <= 113 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - lizardMpValue > 0): lizardButton = False lizardList.append(Lizard(player.x)) lizardCount += 1 player.mp -= lizardMpValue elif(117 <= event.x and event.x <= 143 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - gemumuMpValue > 0): gemumuButton = False gemumuList.append(Gemumu(player.x)) gemumuCount += 1 player.mp -= gemumuMpValue elif(147 <= event.x and event.x <= 173 and 18 <= 600 - event.y and 600 - event.y <= 58): if(player.mp - magicianMpValue > 0): magicianButton = False magicianList.append(Magician(player.x)) magicianCount += 1 player.mp -= magicianMpValue else: player.handle_events(event)