def handle_events(): global Cursor_x, Cursor_y events = get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() elif event.type == SDL_MOUSEMOTION: # 마우스 움직일 때 Cursor_x, Cursor_y = event.x, main_state.WindowHeight - 1 - event.y elif event.type == SDL_KEYDOWN and event.key == SDLK_SPACE and main_state.O_Type == 1: if main_state.Cost >= 10: main_state.Cost -= 10 main_state.Ally.append( Object.Ally(main_state.O_Type, Cursor_x, Cursor_y)) elif event.type == SDL_KEYDOWN and event.key == SDLK_SPACE and main_state.O_Type == 2: if main_state.Cost >= 20: main_state.Cost -= 20 main_state.Ally.append( Object.Ally(main_state.O_Type, Cursor_x, Cursor_y)) elif event.type == SDL_KEYDOWN and event.key == SDLK_SPACE and main_state.O_Type == 3: if main_state.Cost >= 10: main_state.Cost -= 10 main_state.Ally.append( Object.Ally(main_state.O_Type, Cursor_x, Cursor_y)) elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: # esc key 커서 복귀 main_state.O_Type = 0 elif event.type == SDL_KEYDOWN and event.key == SDLK_1: main_state.O_Type = 1 elif event.type == SDL_KEYDOWN and event.key == SDLK_2: main_state.O_Type = 2 elif event.type == SDL_KEYDOWN and event.key == SDLK_3: main_state.O_Type = 3 elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_RETURN): game_framework.pop_state() pass
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_p: game_framework.pop_state()
def update(): if battle_ui.get_escape(): battle_ui.set_escape(False) game_framework.pop_state() for game_object in game_world.all_objects(): game_object.update()
def handle_events(frame_time): events = get_events() for event in events: if(event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): game_framework.quit() elif(event.type, event.key) == (SDL_KEYDOWN, SDLK_r): game_framework.pop_state()
def handle_events(): global choose_menu_pivot_num 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.pop_state() elif event.type == SDL_MOUSEMOTION: if (event.x < 535 and event.x > 265): if (window_to_pico_coordinate_system(event.y) < 358 and window_to_pico_coordinate_system(event.y) > 264): choose_menu_pivot_num = resume elif (window_to_pico_coordinate_system(event.y) < 124 and window_to_pico_coordinate_system(event.y) > 34): choose_menu_pivot_num = exit else: choose_menu_pivot_num = none_select else: choose_menu_pivot_num = none_select elif event.type == SDL_MOUSEBUTTONDOWN: if (choose_menu_pivot_num == resume): game_framework.pop_state() elif (choose_menu_pivot_num == exit): game_framework.quit()
def handle_events(): global x, y, Button_Motion 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.pop_state() if(event.type, event.key) == (SDL_MOUSEMOTION, None): x, y = event.x, 500 - event.y - 1 if 405 - 81 <= x <= 405 + 81: if 115 - 26 <= y <= 115 + 26: Button_Motion = 1 else: Button_Motion = 0 else: Button_Motion = 0 if (event.type, event.button) == (SDL_MOUSEBUTTONDOWN, SDL_BUTTON_LEFT): if Button_Motion == 1: game_world.clear() game_framework.change_state(interface_state) else: pass
def update(): global confirm,expedition,start_time windcursor.update() birddraw.update() expedition_confirm.update() if main_state.mx >= 335 and main_state.mx <= 465 and main_state.my >=22 and main_state.my <= 104: game_framework.pop_state()
def handle_events(): events = get_events() for key in events: if key.type == SDL_QUIT: gf.quit() elif (key.type, key.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gf.pop_state()
def handle_events(): global road, player events = pico2d.get_events() for e in events: if e.type == pico2d.SDL_QUIT: game_framework.quit() elif e.type == pico2d.SDL_KEYDOWN: if e.key == pico2d.SDLK_ESCAPE: game_framework.pop_state() elif e.key == pico2d.SDLK_LEFT: player.car.dir -= 1 elif e.key == pico2d.SDLK_RIGHT: player.car.dir += 1 elif e.key == pico2d.SDLK_DOWN: player.car.accel -= DELAY*10*math.log2(player.car.level + 1) elif e.key == pico2d.SDLK_UP: player.car.accel += DELAY*10*math.log2(player.car.level + 1) elif e.type == pico2d.SDL_KEYUP: if e.key == pico2d.SDLK_LEFT: player.car.dir += 1 elif e.key == pico2d.SDLK_RIGHT: player.car.dir -= 1 elif e.key == pico2d.SDLK_UP: player.car.accel -= DELAY*10*math.log2(player.car.level + 1) elif e.key == pico2d.SDLK_DOWN: player.car.accel += DELAY*10*math.log2(player.car.level + 1)
def handle_events(): global boys global span events = get_events() for e in events: if e.type == SDL_QUIT: game_framework.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: game_framework.pop_state() elif e.key in range(SDLK_1, SDLK_9 + 1): span = 20 * (e.key - SDLK_0) elif e.type == SDL_MOUSEBUTTONDOWN: if e.button == SDL_BUTTON_LEFT: tx, ty = e.x, 600 - e.y for b in boys: bx = tx + random.randint(-span, span) by = ty + random.randint(-span, span) b.waypoints += [(bx, by)] b.determine_state() else: for b in boys: b.waypoints = [] b.determine_state()
def fading(self): if self.game_state == START: self.start_image.draw(800, 450, 1600, 900) if self.timer >= 100: self.game_state = RUNNING elif self.timer >= 50: opacity = 1 - (self.timer - 50)/50 self.start_image.opacify(opacity) else: self.big_font.draw(650, 450, 'stage %d' %main_state.Data.stage_num, (255, 255, 255)) elif self.game_state == END: if self.timer >= 100: game_framework.pop_state() self.start_image.draw(800, 450, 1600, 900) elif self.timer >= 50: opacity = (self.timer - 50) / 50 self.start_image.opacify(opacity) self.start_image.draw(800, 450, 1600, 900) else: self.biggest_font.draw(630, 450, '승리!', (0, 0, 0)) elif self.game_state == FAIL: if self.timer >= 100: self.start_image.draw(800, 450, 1600, 900) elif self.timer >= 0: opacity = self.timer / 100 self.start_image.opacify(opacity) self.start_image.draw(800, 450, 1600, 900)
def handle_events(frame_time): global x, y events = get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() elif event.type == SDL_KEYDOWN and event.key == SDLK_b: main_state.room.bgm.resume() game_framework.pop_state() elif event.type == SDL_MOUSEMOTION: x, y = event.x, 600 - event.y elif event.type == SDL_MOUSEBUTTONDOWN: if main_state.collide(hp_max_up, x, y): if main_state.student.gold > hp_max_up.price: main_state.buy_bgm.play() hp_max_up.update(frame_time) else: main_state.warning_bgm.play() elif main_state.collide(damage_up, x, y): if main_state.student.gold > damage_up.price: main_state.buy_bgm.play() damage_up.update(frame_time) else: main_state.warning_bgm.play() pass
def handle_events(): global x, y, Resume_Motion, Esc_Motion 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.pop_state() if (event.type, event.key) == (SDL_MOUSEMOTION, None): x, y = event.x, 500 - event.y - 1 if 400 - 148 <= x <= 400 + 148: if 313 - 47 <= y <= 313 + 47: Resume_Motion = 1 else: Resume_Motion = 0 if 186 - 47 <= y <= 186 + 47: Esc_Motion = 1 else: Esc_Motion = 0 else: Resume_Motion = 0 Esc_Motion = 0 if (event.type, event.button) == (SDL_MOUSEBUTTONDOWN, SDL_BUTTON_LEFT): if Resume_Motion == 1: print('resume') game_framework.pop_state() elif Esc_Motion == 1: print('esc') game_world.clear() game_framework.change_state(interface_state) else: pass
def handle_events(): global frame 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.pop_state() elif(event.type, event.key) == (SDL_KEYDOWN, SDLK_RETURN): if frame == 0: title_state.choiceMusic() game_framework.pop_state() elif frame == 1: title_state.choiceMusic() game_framework.change_state(main_game) else: game_framework.quit() elif(event.type, event.key) == (SDL_KEYDOWN, SDLK_UP): title_state.selectMusic() if frame > 0: frame -= 1 elif(event.type, event.key) == (SDL_KEYDOWN, SDLK_DOWN): title_state.selectMusic() if frame < 2: frame += 1
def handle_events(): global player,sword events = get_events() for e in events: if e.type == SDL_QUIT: game_framework.quit() if (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): game_framework.pop_state() if (e.type) == (SDL_KEYDOWN): if e.key == SDLK_a: player.attacking = True player.dig() if (e.type) == (SDL_KEYDOWN): if e.key == SDLK_RIGHT or e.key == SDLK_LEFT or e.key == SDLK_UP or e.key == SDLK_DOWN : if e.key == SDLK_RIGHT and right_key_lock == False: #False라는건 잠금이 해제되었다는뜻이므로 진입가능 player.set_dir(2) box.dir = 1 player.moving = True elif e.key == SDLK_LEFT and left_key_lock == False: player.set_dir(1) box.dir = 2 player.moving = True elif e.key == SDLK_UP and up_key_lock == False: box.dir = 3 player.moving = True elif e.key == SDLK_DOWN and down_key_lock == False: box.dir = 4 player.moving = True if player.moving: player.set_state(boy.RunState) else : player.set_state(boy.IdleState) player.moving = False player.wall_touch = False
def handle_events(): global select_menu events = get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() else: if ((event.type, event.button) == (SDL_MOUSEBUTTONDOWN, SDL_BUTTON_RIGHT)): if select_menu == 0: game_framework.pop_state() else: select_menu = 0 elif ((event.type, event.button) == (SDL_MOUSEBUTTONDOWN, SDL_BUTTON_LEFT)): if Function.PointInRect(event.x, event.y, 0, 113, 51, 149): select_menu = 1 elif Function.PointInRect(event.x, event.y, 0, 113, 151, 249): select_menu = 2 elif Function.PointInRect(event.x, event.y, 0, 113, 251, 349): select_menu = 3 if select_menu == 1: if Function.PointInRect(event.x, event.y, 125, 260, 130, 160): game_framework.change_state(prepare_battle) select_menu = 0
def onClick(context): global garage, player_info if context == 'racestart': game_framework.push_state(racing_state) if context == 'buy': have = player_info['coin'] cost = car_info[str(garage.slot[garage.select])]['cost'] if have >= cost: player_info['coin'] -= cost player_info['level'] += 1 player_info['have'].append(garage.slot[garage.select]) save_data() else: pass if context == 'before': game_framework.pop_state() if context == 'la': if garage.slot[0] > 0: garage.slot = [x - 1 for x in garage.slot] if context == 'ra': if garage.slot[2] < MAX_LEV - 1: garage.slot = [x + 1 for x in garage.slot] if context[0] == 's' and len(context) == 2: if context == 's1': garage.select = 0 if context == 's2': garage.select = 1 if context == 's3': garage.select = 2 if context == 'diff_up': garage.difficulty = pico2d.clamp(0, garage.difficulty + 1, 5) if context == 'diff_down': garage.difficulty = pico2d.clamp(0, garage.difficulty - 1, 5)
def handle_events(frame_time): global space, soldier, soldier_bullet_team, tower, ship_bullet_team, alien_team 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.pop_state() else: soldier.handle_events(event) if event.type == SDL_MOUSEBUTTONDOWN: for bullet in soldier_bullet_team: if bullet.what_state(): bullet.shot(soldier, event.x, 1000 - event.y) break if event.type == SDL_KEYDOWN: if event.key in (SDLK_LSHIFT, SDLK_RSHIFT): if soldier.in_go_defence(): soldier.game_defence() for bullet in soldier_bullet_team: bullet.game_defence() for bullet in ship_bullet_team: bullet.game_defence() space.game_defence() tower.game_defence() elif event.key == SDLK_RCTRL: for bullet in ship_bullet_team: if bullet.what_state(): bullet.shot(soldier) break
def handle_events(): global blink_time events = get_events() for event in events: if event.type == SDL_KEYDOWN and event.key == SDLK_p: blink_time = False game_framework.pop_state()
def handle_events(): events = get_events() for event in events: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_p): game_framework.pop_state() elif event.type == SDL_QUIT: game_framework.quit()
def handle_events(): events = get_events() global running global move, reverse for event in events: if event.type == SDL_QUIT: game_framework.quit() elif event.type == SDL_MOUSEBUTTONDOWN and event.button == SDL_BUTTON_LEFT: if 450 < event.x < 490 and 750 < 800 - event.y < 790: if running == False: resume() else: pause() if 180 < event.x < 320 and 375 < 800 - event.y < 425: if running == False: game_framework.change_state(main_state) if 210 < event.x < 290 and 320 < 800 - event.y < 360: if running == False: resume() else: if event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: game_framework.quit() elif event.type == SDL_KEYDOWN and event.key == SDLK_BACKSPACE: game_framework.pop_state() elif event.type == SDL_KEYDOWN and event.key == SDLK_a: move = True reverse = False elif event.type == SDL_KEYDOWN and event.key == SDLK_d: move = True reverse = True elif event.type == SDL_KEYUP: move = False pass
def handle_events(frame_time): 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.pop_state() if event.type == SDL_MOUSEMOTION: if tutorial.handle_event(event): tutorial.big_next() else: tutorial.small_next() if event.type == SDL_MOUSEBUTTONDOWN: if tutorial.bullet_tutorial(): for bullet in soldier_bullet_team: if bullet.what_state(): bullet.shot(soldier, event.x, 1000 - event.y) break if event.type == SDL_MOUSEBUTTONDOWN: if tutorial.handle_event(event): tutorial.next_tutorial() else: soldier.handle_events(event)
def handle_events(): global player, gameState, ball events = get_events() for e in events: if e.type == SDL_QUIT: game_framework.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): game_framework.pop_state() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): toggle_paused() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_q): ball.speed *= 2 elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_e): ball.speed /= 2 elif e.type == SDL_MOUSEBUTTONDOWN: if player.mouse_control: toggle_paused() return handled = player.handle_event(e) if handled: if gameState == GAMESTATE_READY: start_game() elif gameState == GAMESTATE_PAUSED: gameState = GAMESTATE_INPLAY ui.handle_event(e)
def handle_events(): events = get_events() for e in events: if e.type == SDL_QUIT: game_framework.quit() if e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: game_framework.pop_state()
def handle_events(): global player, barrel, test events = get_events() for key in events: if key.type == SDL_QUIT: gf.quit() elif (key.type, key.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gf.pop_state() else: player.handle_event(key)
def update(): if battle_state.player.get_player( battle_state.battle_ui.get_player_now()).get_turn() == 0: battle_state.battle_ui.set_is_main(True) game_framework.pop_state() for game_object in game_world.all_objects(): game_object.update()
def handle_events(frame_time): events = get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_h): game_framework.pop_state()
def handle_events(frame_time): events = get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() elif event.type == SDL_KEYDOWN and event.key == SDLK_p: # p key go to main_state game_framework.pop_state() pass
def handle_events(): global boy events = get_events() for e in events: if e.type == SDL_QUIT: game_framework.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): game_framework.pop_state() ui.handle_event(e)
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.pop_state() game_framework.change_state(title_state)
def handle_events(frame_time): events = get_events() for event in events: if event.type == SDL_MOUSEBUTTONDOWN: if collision.point_in_rect(event.x, game_framework.height - event.y, \ game_framework.width - pause_image.w // 2 - 10, game_framework.height - pause_image.h // 2 - 10, pause_image.w, pause_image.h): game_framework.pop_state() break
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.change_state(title_state) elif event.type == SDL_KEYDOWN and event.key == SDLK_l: game_framework.pop_state()
def handle_events(frame_time): events=get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() elif(event.type == SDL_MOUSEMOTION): class_cursor.Cursor.x,class_cursor.Cursor.y=event.x,600-event.y else: if opacify_time <= 0.000 and event.type == SDL_KEYDOWN: game_framework.pop_state()
def drawcard(num): global cardnumber global turntype,font road,wood=1,8 if turntype==1 or turntype==10: card.image[(cardnumber+1)%7].clip_draw(0,0,200,300,150,350)#draw_rectangle(300,200,500,500) card.villege.clip_draw(0,0,200,300,400,350) #draw_rectangle(50,200,250,500) font.draw(340,380,"물건을 산다",color=(150,350,0)) card.villege.clip_draw(0,0,200,300,650,350) #draw_rectangle(50,200,250,500) font.draw(590,380,"휴식한다",color=(150,350,0)) elif turntype==2: if num>=0 and num<5: card.villege.clip_draw(0,0,266,399,150,350) font.draw(90,380,"음식을 잘못먹었다",color=(150,350,0)) font.draw(90,350,"최대체력이 감소한다",color=(150,350,0)) elif num>=5 and num<15: card.villege.clip_draw(0,0,266,399,150,350) font.draw(90,380,"누군가가 돈을",color=(150,350,0)) font.draw(90,350,"훔쳐가버렸다!",color=(150,350,0)) elif num>=15 and num<(map.chracter.luk*5+15): card.villege.clip_draw(0,0,266,399,150,350) font.draw(90,380,"상징적인 물건을",color=(150,350,0)) font.draw(90,350,"얻었다.",color=(150,350,0)) font.draw(90,320,"행운이 증가한다",color=(150,350,0)) font.draw(90,290,"(최대 5까지)",color=(150,350,0)) else: card.villege.clip_draw(0,0,266,399,150,350) font.draw(90,380,"아무일도",color=(150,350,0)) font.draw(90,350,"일어나지 않았다",color=(150,350,0)) elif turntype==3 or turntype==9: card.villege.clip_draw(0,0,200,300,150,350) #draw_rectangle(50,200,250,500) font.draw(90,380,"무기를 산다",color=(150,350,0)) font.draw(90,350,"가격 : %d"%((map.chracter.str-2)*2),color=(150,350,0)) font.draw(90,320,"데미지 +1",color=(150,350,0)) card.villege.clip_draw(0,0,200,300,400,350) #draw_rectangle(50,200,250,500) font.draw(340,380,"방어구를 산다",color=(150,350,0)) font.draw(340,350,"가격 : %d"%((map.chracter.df)*5),color=(150,350,0)) font.draw(340,320,"방어력 +1",color=(150,350,0)) font.draw(340,290,"(최대방어력 5",color=(150,350,0)) font.draw(340,260,"를 넘지 못한다)",color=(150,350,0)) card.villege.clip_draw(0,0,200,300,650,350) #draw_rectangle(50,200,250,500) font.draw(590,380,"회복한다.",color=(150,350,0)) font.draw(590,350,"골드 1당 1회복",color=(150,350,0)) font.draw(590,320,"%d 회복"%itemnumber,color=(150,350,0)) card.villege.clip_draw(25,30,130,50,645,550) #draw_rectangle(50,200,250,500) font.draw(590,550,"+,-키로 수치조절",color=(255,0,0)) if turntype==4: result(actionnumber) map.turnnumber+=1 game_framework.pop_state()
def handle_events(): global my_character, enemy_character 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.pop_state() else: for my_character in character_number: my_character.handle_event(event)
def handle_events(): global x, y events = get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() elif event.type == SDL_MOUSEBUTTONUP and event.button == SDL_BUTTON_LEFT: if (432 < event.x and event.x < 468) and (9 < event.y and event.y < 43): game_framework.pop_state() if (17 < event.x and event.x < 90) and (123 < event.y and event.y < 195): if shop.upgrade_click_damage < 5: shop.upgrade_click_damage += 1 elif event.type == SDL_MOUSEBUTTONDOWN and event.button == SDL_BUTTON_LEFT: pass
def handle_events(frame_time): events = get_events() for event in events: if (event.type == SDL_QUIT): game_framework.quit() elif (event.type == SDL_KEYDOWN): if (event.key == SDLK_h): game_framework.pop_state() elif event.key == SDLK_x: # 타임 리프 시작 Change_time_back(True) elif (event.key == SDLK_ESCAPE): game_framework.stack[-2].exit() del(game_framework.stack[-2]) game_framework.change_state(title_state) elif (event.type == SDL_KEYUP): if (event.key == SDLK_x): Change_time_back(False)
def update(): global title_logo_time if(game_framework.level != 0 and game_framework.heart != 0): bgm = load_music('BGM\\레벨업.ogg') bgm.set_volume(20) bgm.play() game_framework.level +=1 print("레벨 업", game_framework.level) game_framework.push_state(main_state) elif ( game_framework.heart == 0 ): bgm = load_music('BGM\\레벨업.ogg') bgm.set_volume(20) bgm.play() game_framework.pop_state() print("들어옴") if( title_logo_time > 2.0): game_framework.heart = 3 #새생명주자.. game_framework.level = 0 title_logo_time = 0 delay(0.01) title_logo_time +=0.01
def handle_events(): global running,xpos,ypos,actionnumber global map,move,tile,turnnumber,cardnumber global stat,mouse_x,mouse_y,statonoff,itemnumber global pausenum,dice_num,tiletype,turntype 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): if turntype==2 : turntype=4 elif turntype==10 or turntype==9: map.turnnumber+=1 game_framework.pop_state() elif(event.type,event.key)==(SDL_KEYDOWN,SDLK_p): if pausenum==1: pausenum=0 elif pausenum==0:pausenum=1 elif(event.type,event.key)==(SDL_KEYDOWN,SDLK_o): print(actionnumber) elif(event.type,event.key)==(SDL_KEYDOWN,SDLK_i): stat.onoff= not stat.onoff elif(event.type,event.key)==(SDL_KEYDOWN,SDLK_q): game_framework.pop_state() elif(event.type,event.key)==(SDL_KEYDOWN,SDLK_KP_MINUS): if turntype==3 and itemnumber>0: itemnumber-=1 elif(event.type,event.key)==(SDL_KEYDOWN,SDLK_KP_PLUS): if turntype==3 and itemnumber<map.chracter.gold: itemnumber+=1 if (event.type,event.button)==(SDL_MOUSEBUTTONDOWN,SDL_BUTTON_LEFT): mouse_x,mouse_y=event.x,599-event.y if turntype==1 or turntype==3: actionnumber=click_card()
def drawcard(num): global cardnumber global turntype road,wood=1,8 if turntype==1: stat.onoff=1 card.image[cardnumber%7].clip_draw(0,0,200,300,150,350) #draw_rectangle(50,200,250,500) card.image[(cardnumber+1)%7].clip_draw(0,0,200,300,400,350)#draw_rectangle(300,200,500,500) card.image[(cardnumber+2)%7].clip_draw(0,0,200,300,650,350)#draw_rectangle(550,200,750,500) elif turntype==3: if num>=0 and num<(map.chracter.luk*3)+2: card.ruins.clip_draw(0,0,266,399,150,350) font.draw(90,380,"새로운 무기를",color=(150,350,0)) font.draw(90,350,"얻었다. (힘+1)",color=(150,350,0)) font.draw(90,320,"(최대 12)",color=(150,350,0)) elif num>=(map.chracter.luk*3)+2 and num<((map.chracter.luk*3)+2)*2: card.ruins.clip_draw(0,0,266,399,150,350) font.draw(90,380,"새로운 방어구를",color=(150,350,0)) font.draw(90,350,"얻었다. (방어+1)",color=(150,350,0)) font.draw(90,320,"(최대 5)",color=(150,350,0)) elif num<((map.chracter.luk*3)+2)*2+5 and num<((map.chracter.luk*3)+2)*2+10: card.ruins.clip_draw(0,0,266,399,150,350) font.draw(90,380,"무기가 오래되어",color=(150,350,0)) font.draw(90,350,"부식되었다. (방어-1)",color=(150,350,0)) font.draw(90,320,"(최소 1)",color=(150,350,0)) elif num<((map.chracter.luk*3)+2)*2+10 and num<((map.chracter.luk*3)+2)*2+15: card.ruins.clip_draw(0,0,266,399,150,350) font.draw(90,380,"떨어지는 바위에 ",color=(150,350,0)) font.draw(90,350,"방어구가 망가졌다",color=(150,350,0)) font.draw(90,320,"(방어 -1, 최소 1)",color=(150,350,0)) else: card.ruins.clip_draw(0,0,266,399,150,350) font.draw(90,380,"발견된 것이",color=(150,350,0)) font.draw(90,350,"없다",color=(150,350,0)) if turntype==4: result(actionnumber) game_framework.pop_state()
def handle_events(frame_time): global battle_step,cursor events=get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() elif event.type == SDL_KEYDOWN: if event.key == SDLK_ESCAPE: game_framework.quit() elif event.key == SDLK_z: if battle_step == STEP_ENEMY_TURN: battle_step +=1 rolling_sound.play() elif battle_step == STEP_USER_TURN: battle_step+=1 elif battle_step ==STEP_SELECT_TOOLS and int(Criminal_Tool.check_state / 10)!=0 and int(Criminal_Tool.check_state % 10)!=0: battle_step +=1 elif battle_step == STEP_CHECK_RESULT: battle_step +=1 elif battle_step == STEP_TURN_END: if Player.hp == 0: battle_lose() battle_step +=1 elif enemy.hp == 0: battle_win() battle_step +=1 else: initialize_turn() elif battle_step == STEP_BATTLE_END: initialize_turn() game_framework.pop_state() if(event.type == SDL_MOUSEMOTION): class_cursor.Cursor.x, class_cursor.Cursor.y=event.x,600-event.y for tool in tool_group: #손가락을 펼치는 조건들 if battle_step == STEP_SELECT_TOOLS and collide(event.x,600-event.y,tool) and tool.state == tool.IDLE and ( int(Criminal_Tool.check_state / 10)==0 or int(Criminal_Tool.check_state % 10)==0): cursor.state = cursor.PAPER break else: cursor.state = cursor.IDLE for tool in tool_group: if tool.state == tool.GRABBED: cursor.state = cursor.ROCK tool.x=event.x tool.y=600-event.y if(event.type == SDL_MOUSEBUTTONDOWN): if (event.button == SDL_BUTTON_LEFT) and ( int(Criminal_Tool.check_state / 10)==0 or int(Criminal_Tool.check_state % 10)==0): for tool in tool_group: if battle_step == STEP_SELECT_TOOLS and collide(event.x,600-event.y,tool) and tool.state == tool.IDLE: click_sound.play() cursor.state=cursor.ROCK tool.x=event.x tool.y= 600-event.y tool.state = tool.GRABBED if tool.type == tool.HAMMER: textbox.wait = 1 textbox.string1 = " [망치] " textbox.string2 = " 왼쪽 숫자 + 오른쪽 숫자 " textbox.string3 = " 연산우선순위 4번째 " textbox.string4 = " " elif tool.type ==tool.CHAIN: textbox.wait = 1 textbox.string1 = " [쇠사슬] " textbox.string2 = " 왼쪽 숫자 - 오른쪽 숫자 " textbox.string3 = " 연산우선순위 3번째 " textbox.string4 = " " elif tool.type ==tool.SPANNER: textbox.wait = 1 textbox.string1 = " [스패너] " textbox.string2 = " 왼쪽 숫자 x 오른쪽 숫자 " textbox.string3 = " 연산우선순위 2번째 " textbox.string4 = "스패너는 한 턴에 한번만 사용할 수 있습니다." elif tool.type ==tool.KNIFE: textbox.wait = 1 textbox.string1 = " [칼] " textbox.string2 = " '작은수~큰수' 사이 모든 수의 합 " textbox.string3 = " 연산우선순위 1번째 " textbox.string4 = "칼은 한 턴에 한번만 사용할 수 있습니다." if (event.button == SDL_BUTTON_RIGHT): for tool in tool_group: if battle_step == STEP_SELECT_TOOLS and collide(event.x,600-event.y,tool): click_sound.play() if tool.state == tool.FIRST_SELECTED: Criminal_Tool.check_state -=10*tool.type tool_group.remove(tool) elif tool.state == tool.SECOND_SELECTED: Criminal_Tool.check_state -=tool.type tool_group.remove(tool) elif(event.type == SDL_MOUSEBUTTONUP and event.button ==SDL_BUTTON_LEFT and event.button !=SDL_BUTTON_RIGHT): cursor.state=cursor.IDLE for tool in tool_group: if tool.state ==tool.GRABBED: toolbox=collide_toolbox(tool) first_box_type = int(Criminal_Tool.check_state / 10) # 첫번째 연산기호 (십의 자리) second_box_type = int(Criminal_Tool.check_state % 10) # 두번째 연산기호 (일의 자리) textbox.wait=0 if first_box_type == 0 and toolbox == 1 and (tool.type < tool.SPANNER or tool.type !=second_box_type): # 첫번째칸이 비었고, 첫번째 안에서 마우스버튼을 떼었을 때 finish_sound.play() tool.state = tool.FIRST_SELECTED #첫번째 칸 tool.x, tool.y = tool.First_x,tool.First_y Criminal_Tool.check_state +=10*tool.type tool_group.append(Criminal_Tool(tool.type)) elif second_box_type == 0 and toolbox == 2 and (tool.type < tool.SPANNER or tool.type !=first_box_type): finish_sound.play() tool.state = tool.SECOND_SELECTED #두번째 칸 tool.x, tool.y = tool.Second_x,tool.Second_y Criminal_Tool.check_state +=tool.type tool_group.append(Criminal_Tool(tool.type)) else: tool.__init__(tool.type) #원래 자리로 초기화
def exit(): global boy del(boy) close_canvas() game_framework.pop_state()