def open_skill_menu(): open_inner_menu("skill") g.cur_window = "inventory_skill" refresh_skill("skill") refresh_skill_buttons() while 1: pygame.time.wait(30) g.clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: tmp = skill_key_handler(event.key) if tmp == 1: return elif tmp == "end": return "end" elif event.type == pygame.MOUSEMOTION: skill_mouse_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if skill_mouse_click(event.pos) == 1: return tmpjoy = g.run_joystick() if tmpjoy != 0: if skill_key_handler(tmpjoy) == 1: return menu_bind_keys()
def open_drop_item(): open_inner_menu("drop") g.cur_window = "inventory_drop" refresh_drop() refresh_drop_buttons() # g.window_main.wait_variable(back_to_inv) # if main.canvas_map.winfo_exists(): # main.canvas_map.delete("drop") while 1: pygame.time.wait(30) g.clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: if drop_key_handler(event.key) == 1: return elif event.type == pygame.MOUSEMOTION: drop_mouse_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if drop_mouse_click(event.pos) == 1: return tmpjoy = g.run_joystick() if tmpjoy != 0: if drop_key_handler(tmpjoy) == 1: return menu_bind_keys()
def main_loop(self): while 1: pygame.time.wait(30) g.clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: self.state = QUIT return elif event.type == pygame.KEYDOWN: self.key_handler(event.key) elif event.type == pygame.MOUSEMOTION: self.mouse_xy = event.pos self.mouse_handler_move() elif event.type == pygame.MOUSEBUTTONDOWN: self.mouse_xy = event.pos self.mouse_handler_move() self.mouse_handler_down() tmpjoy = g.run_joystick() if tmpjoy: self.key_handler(tmpjoy) if g.unclean_screen: g.unclean_screen = False pygame.display.flip() if self.state: return
def init_window_options(): global curr_button curr_button = 0 global tmp_fullscreen global tmp_difficulty global tmp_keys global tmp_joystick global tmp_joy tmp_fullscreen = g.fullscreen tmp_difficulty = g.difficulty tmp_joystick = g.use_joy tmp_keys = {} tmp_keys["up"] = g.bindings["up"] tmp_keys["down"] = g.bindings["down"] tmp_keys["right"] = g.bindings["right"] tmp_keys["left"] = g.bindings["left"] tmp_keys["action"] = g.bindings["action"] tmp_keys["cancel"] = g.bindings["cancel"] tmp_joy = {} tmp_joy["lr"] = g.joy_axis0 tmp_joy["ud"] = g.joy_axis1 tmp_joy["action"] = g.joykey_action tmp_joy["cancel"] = g.joykey_cancel refresh_window() while 1: pygame.time.wait(30) g.clock.tick(30) if g.break_one_loop > 0: g.break_one_loop -= 1 break for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: key_handler(event.key) repeat_key = 0 #elif event.type == pygame.KEYUP: #key_handler_up(event.key) elif event.type == pygame.MOUSEMOTION: mouse_handler_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if mouse_handler_down(event.pos) == 1: return tmpjoy = g.run_joystick() if tmpjoy != 0: key_handler(tmpjoy)
def custom_joy(): refresh_joy_window() while 1: pygame.time.wait(30) g.clock.tick(30) if g.break_one_loop > 0: g.break_one_loop -= 1 break for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: joy_key_handler(event.key) repeat_key = 0 elif event.type == pygame.MOUSEMOTION: mouse_handler_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if mouse_handler_down(event.pos) == 1: return tmpjoy = g.run_joystick() if tmpjoy != 0: joy_key_handler(tmpjoy)
def open_item_menu(): #don't do anything if battle is over. if can_leave() == 1: return 0 tmp_surface = pygame.Surface((300, 420)) tmp_surface.blit(g.screen, (0, 0), (170, 0, 300, 420)) inv.open_inner_menu("use") bind_item_keys() inv.inner_cur_button = 0 # g.window_main.update_idletasks() inv.refresh_inv_display("use") inv.refresh_inner_buttons("use") while 1: pygame.time.wait(30) g.clock.tick(30) if g.break_one_loop > 0: g.break_one_loop -= 1 break for event in pygame.event.get(): if event.type == pygame.QUIT: g.break_one_loop = 3 elif event.type == pygame.KEYDOWN: if item_key_handler(event.key) == 2: break elif event.type == pygame.MOUSEMOTION: item_mouse_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: item_mouse_click(event.pos) tmpjoy = g.run_joystick() if tmpjoy != 0: item_key_handler(tmpjoy) if g.unclean_screen: pygame.display.flip() g.screen.blit(tmp_surface, (170, 0)) refresh() refresh_buttons() pygame.display.flip() bind_keys()
def open_equip_item(): global curr_item open_inner_menu("equip") #Equip also needs the equip screen: temp_canvas_width = (g.tilesize * equip_size) + 8 g.create_norm_box((tmp_x_base - temp_canvas_width, tmp_y_base), (temp_canvas_width, temp_canvas_width)) g.cur_window = "inventory_equip" refresh_equip() refresh_equip_buttons() while 1: pygame.time.wait(30) g.clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: if equip_key_handler(event.key) == 1: if curr_item >= inv_width * inv_height: curr_item = 0 return elif event.type == pygame.MOUSEMOTION: equip_mouse_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if equip_mouse_click(event.pos) == 1: if curr_item >= inv_width * inv_height: curr_item = 0 return tmpjoy = g.run_joystick() if tmpjoy != 0: if equip_key_handler(tmpjoy) == 1: if curr_item >= inv_width * inv_height: curr_item = 0 return menu_bind_keys()
def select_monster(): #find out if we need to make the player select a monster. num_of_monsters = 0 last_mon_num = 0 for i in range(len(monster_list)): if monster_list[i].hp > 0: num_of_monsters += 1 last_mon_num = i #If there is only one living monster, last_mon_num holds the array location #in monster_list[]. Otherwise, ask the player which monster to attack. if num_of_monsters == 1: return last_mon_num action.has_dialog = 1 global active_button for i in range(len(monster_list)): if monster_list[i].hp > 0: active_button = i break else: print "BUG: select_monster called when all monsters were dead" return -1 global return_from_dialog return_from_dialog = 0 #bindings bind_attack_keys() #Don't want an inv box in the way: #inv.leave_inner() # if main.canvas_map.winfo_exists(): # main.canvas_map.delete("skill") # main.canvas_map.delete("use") refresh() pygame.display.flip() #wait. Continue after activate_yesno() is run. while 1: pygame.time.wait(30) g.clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: g.allow_move = 1 return -1 elif event.type == pygame.KEYDOWN: if event.key == g.bindings["up"] or event.key == g.bindings[ "left"]: choose_monster_prev() refresh() pygame.display.flip() elif event.key == g.bindings[ "down"] or event.key == g.bindings["right"]: choose_monster_next() refresh() pygame.display.flip() elif event.key == g.bindings["action"] or g.bindings["attack"]: g.break_one_loop = 1 elif event.type == pygame.MOUSEMOTION: monster_mouse_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: monster_mouse_move(event.pos) g.break_one_loop = 1 tmpjoy = g.run_joystick() if tmpjoy != 0: #This is a bit odd, but I don't have a keypress function for #the dialog. pygame.event.post(pygame.event.Event(pygame.KEYDOWN, key=tmpjoy)) pygame.event.post(pygame.event.Event(pygame.KEYUP, key=tmpjoy)) if g.break_one_loop > 0: g.break_one_loop -= 1 break if g.unclean_screen: pygame.display.flip() #cleanup if return_from_dialog == 2: return -1 else: bind_keys() action.has_dialog = 0 refresh() return active_button
def begin(mon_index_input): # global window_battle global bgcolour bgcolour = "lightgrey" # window_battle = Frame(g.window_main, bd=4, relief=GROOVE, bg=bgcolour) # window_battle.grid(row=0, column=0) global mon_index mon_index = mon_index_input global monster_list monster_list = [] for line in monster.monster_groups[mon_index].monster_list: monster_list.append( monster.copy_monster( monster.monsters[monster.monster_name_to_index(line)])) for i in range(len(monster_list)): monster_list[i].reset() if g.difficulty == 0: monster_list[i].hp -= monster_list[i].hp / 5 monster_list[i].maxhp -= monster_list[i].maxhp / 5 monster_list[i].attack -= monster_list[i].attack / 5 monster_list[i].defense -= monster_list[i].defense / 5 if g.difficulty == 2: monster_list[i].hp += monster_list[i].hp / 5 monster_list[i].maxhp += monster_list[i].maxhp / 5 monster_list[i].attack += monster_list[i].attack / 5 monster_list[i].defense += monster_list[i].defense / 5 global did_run did_run = 0 global cur_button cur_button = 0 global run_attempts run_attempts = 0 global active_button active_button = -1 # Set the current window g.cur_window = "battle" global canvas_mon_pic global background_pic background_pic = g.maps[g.zgrid].battle_background global monster_pic monster_pic = [] global base_mon_hp_start base_mon_hp_start = [] global base_mon_hp_width base_mon_hp_width = [] global base_mon_hp_y_start base_mon_hp_y_start = [] global monster_slashes monster_slashes = [] global monster_start monster_start = (main.tilesize * main.half_mapx - background_pic.get_width() / 2, main.tilesize * main.half_mapy - background_pic.get_height() / 2) for i in range(len(monster_list)): monster_slashes.append([0, 0, 0]) try: monster_pic.append(g.tiles["monsters/" + monster_list[i].name + ".png"]) except KeyError: monster_pic.append(g.tiles["monsters/generic.png"]) #if x and y positions were given, use them; otherwise, start at the #middle, and go right. This works for 1 or two monsters, but xy #coords are recommended for more. if len(monster.monster_groups[mon_index].x_pos) > i: xstart = monster_start[0] + monster.monster_groups[ mon_index].x_pos[i] else: xstart = monster_start[0] + background_pic.get_width() / 2 + i * 40 ystart = y_start(i) base_mon_hp_start.append(xstart - monster_pic[i].get_width() / 2) base_mon_hp_width.append(monster_pic[i].get_width()) base_mon_hp_height.append(monster_pic[i].get_height()) base_mon_hp_y_start.append(ystart + 5 + monster_pic[i].get_height()) monster_slashes.append([0, 0, 0]) global hero_pic try: hero_pic = g.tiles["people/hero_n" + g.maps[g.zgrid].hero_suffix + ".png"] except KeyError: hero_pic = g.tiles["blank"] global hero_loc hero_loc = (monster_start[0] + (background_pic.get_width() - base_mon_hp_width[0]) / 2, background_pic.get_height() - hero_pic.get_height() * 5 / 2 + monster_start[1]) global attack_button_loc global item_button_loc global skill_button_loc global inspect_button_loc global run_button_loc global final_button_loc global button_y_start global button_height attack_button_loc = main.tilesize * main.half_mapx - \ g.buttons["attack.png"].get_width() - g.buttons["use.png"].get_width() - \ g.buttons["skill.png"].get_width() / 2 item_button_loc = attack_button_loc + g.buttons["attack.png"].get_width() skill_button_loc = item_button_loc + g.buttons["use.png"].get_width() inspect_button_loc = skill_button_loc + g.buttons["skill.png"].get_width() run_button_loc = inspect_button_loc + g.buttons["inspect.png"].get_width() final_button_loc = run_button_loc + g.buttons["quit.png"].get_width() button_y_start = main.tilesize * main.half_mapy + background_pic.get_height( ) / 2 button_height = g.buttons["attack.png"].get_height() g.create_norm_box((attack_button_loc, button_y_start), (final_button_loc - attack_button_loc, button_height)) #bindings bind_keys() main.print_message(monster.monster_groups[mon_index].attack_message) set_description_text(0) refresh() refresh_buttons() while 1: pygame.time.wait(30) g.clock.tick(30) if g.break_one_loop > 0: g.break_one_loop -= 1 break for event in pygame.event.get(): if event.type == pygame.QUIT: g.break_one_loop = 2 elif event.type == pygame.KEYDOWN: if key_handler(event.key) == 1: break elif event.type == pygame.MOUSEMOTION: if (event.pos[1] > button_y_start and event.pos[1] < button_height + button_y_start): mouse_handler_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: mouse_handler_move(event.pos) if key_handler(pygame.K_RETURN) == 1: break tmpjoy = g.run_joystick() if tmpjoy != 0: key_handler(tmpjoy) if g.unclean_screen: pygame.display.flip() if player.hp <= 0: did_run = "end" return did_run
def init_window_loadgame(): #create the window global prevent_dbl_load prevent_dbl_load = 0 g.create_norm_box((g.tilesize * g.main.mapsizex / 4 - 2, g.tilesize * g.main.mapsizey / 3 - 2), (g.tilesize * g.main.mapsizex / 2 + 2, +140 + g.buttons["load_scr.png"].get_height() + 2)) global did_load did_load = "" #add the saves images g.screen.blit( g.buttons["loadgame_up.png"], (g.tilesize * g.main.mapsizex / 4, g.tilesize * g.main.mapsizey / 3)) g.screen.blit( g.buttons["loadgame_down.png"], (g.tilesize * g.main.mapsizex / 4, g.tilesize * g.main.mapsizey / 3 + 140 - g.buttons["loadgame_down.png"].get_height())) pixels_per_line = 20 #If there is no save directory, make one. if path.isdir(g.mod_directory + "/saves") == 0: if path.exists(g.mod_directory + "/saves") == 1: remove(g.mod_directory + "/saves") mkdir(g.mod_directory + "/saves") #show the files contained in the saves directory. global saves_array saves_array = [] tmp_saves_array = listdir(g.mod_directory + "/saves") for save_name in tmp_saves_array: if save_name[:1] != "." and save_name != "CVS": saves_array.append(save_name) global saves_pos saves_pos = 0 refresh_buttons() refresh_save_info() global repeat_key repeat_key = 0 global key_down key_down = "" while 1: pygame.time.wait(30) g.clock.tick(30) if g.break_one_loop > 0: g.break_one_loop -= 1 break for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: key_handler(event.key) repeat_key = 0 elif event.type == pygame.KEYUP: key_handler_up(event.key) elif event.type == pygame.MOUSEMOTION: mouse_handler_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if mouse_handler_down(event.pos) == 1: return tmpjoy = g.run_joystick() if tmpjoy != 0: if tmpjoy != g.bindings["left"] and tmpjoy != g.bindings["right"]: global cur_button if cur_button != 0: cur_button = 0 refresh_buttons() key_handler(tmpjoy) if g.unclean_screen: pygame.display.flip() return did_load
def init_window_shop(store_type_input): g.cur_window = "shop" global last_click_time last_click_time = 0 global prev_button prev_button = 1 global temp_canvas_width global temp_canvas_height global canvas_x_start global canvas_y_start global temp_button_x global temp_button_width global temp_button_y temp_canvas_width = (g.tilesize * shop_width) + ((shop_width + 1) * 2) + 1 temp_canvas_height = (g.tilesize * shop_height) + ( (shop_height + 1) * 2) + 1 canvas_x_start = ((g.tilesize * main.mapsizex) - temp_canvas_width * 3) / 2 canvas_y_start = ((g.tilesize * main.mapsizey) - temp_canvas_height) / 2 temp_button_x = canvas_x_start + (temp_canvas_width * 3) / 2 - \ g.buttons["sell.png"].get_width() - g.buttons["leave_shop.png"].get_width() / 2 temp_button_width = g.buttons["sell.png"].get_width() + \ g.buttons["leave_shop.png"].get_width() + g.buttons["buy.png"].get_width() temp_button_y = canvas_y_start + temp_canvas_height + 1 global bgcolour bgcolour = "light_grey" g.create_norm_box((canvas_x_start - 2, canvas_y_start - 19), (temp_canvas_width * 3 + 3, temp_canvas_height + 20)) global curr_item curr_item = 0 global curr_focus curr_focus = 1 global cur_button cur_button = 2 store_type_input = store_type_input.lower() global store_num for i in range(len(g.shops)): if (g.shops[i].name.lower() == store_type_input): store_num = i break g.create_norm_box((canvas_x_start, canvas_y_start), (temp_canvas_width - 1, temp_canvas_height - 1)) #per-item borders for y in range(shop_height): for x in range(shop_width): g.create_norm_box( (canvas_x_start + x * g.tilesize + 2 * (x + 1), canvas_y_start + y * g.tilesize + 2 * (y + 1)), (g.tilesize, g.tilesize), inner_color="dh_green") g.create_norm_box((temp_canvas_width * 2 + canvas_x_start, canvas_y_start), (temp_canvas_width - 1, temp_canvas_height - 1)) #per-item borders for y in range(shop_height): for x in range(shop_width): g.create_norm_box( (temp_canvas_width * 2 + canvas_x_start + x * g.tilesize + 2 * (x + 1), canvas_y_start + y * g.tilesize + 2 * (y + 1)), (g.tilesize, g.tilesize), inner_color="dh_green") #Info labels g.print_string(g.screen, "Inventory", g.font, (canvas_x_start + (temp_canvas_width * 1) / 2, canvas_y_start - 15), align=1) g.print_string(g.screen, g.shops[store_num].name, g.font, (canvas_x_start + (temp_canvas_width * 5) / 2, canvas_y_start - 15), align=1) # main.canvas_map.create_text(canvas_x_start+(temp_canvas_width*1)/2, # canvas_y_start-1, anchor=S, text="Inventory", tags="shop") # main.canvas_map.create_text(canvas_x_start+(temp_canvas_width*5)/2, # canvas_y_start-1, anchor=S, text=g.shops[store_num].name, tags="shop") global leave_height leave_height = g.buttons["sell.png"].get_width() global buy_height buy_height = leave_height + g.buttons["leave.png"].get_width() #get data in listboxes # refresh_inv() refresh_shop() refresh_buttons() # main.canvas_map.unbind("<Motion>") #main.canvas_map.unbind("<Button-1>") show_details() pygame.display.flip() g.last_joy_times["ud"] = pygame.time.get_ticks() g.last_joy_times["lr"] = pygame.time.get_ticks() while 1: pygame.time.wait(30) g.clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: if key_handler(event.key) == 1: return elif event.type == pygame.MOUSEMOTION: mouse_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if mouse_sel_shop(event.pos) == 1: return tmpjoy = g.run_joystick() if tmpjoy != 0: if key_handler(tmpjoy) == 1: return
def init_window(): #global g.window_main # g.window_main = Toplevel() pygame.display.set_caption(g.game_name) # g.window_main.title(g.game_name) global bgcolour bgcolour = "lightgrey" # global canvas_map # main.canvas_map = Canvas(g.window_main, width=g.tilesize*main.mapsizex, # height=g.tilesize*main.mapsizey, highlightthickness=0) # main.canvas_map.grid(column=0, row=0) g.screen.fill(g.colors["black"]) g.screen.blit(g.backgrounds["new_game.png"], (0, 0)) global name_stat name_stat = g.default_player_name #button coords global button_start button_start = 331 global button_height button_height = g.buttons["begin.png"].get_height() global new_game_width global load_width global options_width global quit_width global final_width new_game_width = g.tilesize * main.mapsizex / 2 - \ g.buttons["begin.png"].get_width() - g.buttons["load.png"].get_width() / 2 load_width = new_game_width + g.buttons["begin.png"].get_width() options_width = load_width + g.buttons["options.png"].get_width() quit_width = options_width + g.buttons["load.png"].get_width() final_width = quit_width + g.buttons["quit.png"].get_width() # g.print_string(g.screen, 15, button_start+button_height/2, anchor=W, # text="", tags="help_text", fill="#ffffff") global cur_button cur_button = 0 refresh_buttons() pygame.display.flip() # #give basic values. # reroll_stats() while 1: pygame.time.wait(30) g.clock.tick(30) if g.break_one_loop > 0: g.break_one_loop -= 1 break for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: if key_handler(event.key) == 1: return elif event.type == pygame.MOUSEMOTION: mouse_handler_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: if key_handler(pygame.K_RETURN) == 1: return tmpjoy = g.run_joystick() if tmpjoy != 0: key_handler(tmpjoy)
def init_window_inv(): # main.canvas_map.delete("inv") global cur_button cur_button = 0 global oldbutton oldbutton = 99 #Location of the various buttons. global equip_height equip_height = g.buttons["use.png"].get_height() global drop_height drop_height = equip_height + g.buttons["equip.png"].get_height() global skill_height skill_height = drop_height + g.buttons["skill.png"].get_height() global save_height save_height = skill_height + g.buttons["drop.png"].get_height() global leave_height leave_height = save_height + g.buttons["save.png"].get_height() global total_height total_height = leave_height + g.buttons["leave.png"].get_height() global button_width button_width = g.buttons["drop.png"].get_width() global base_x base_x = (g.tilesize * main.mapsizex) / 2 - button_width global base_y base_y = (g.tilesize * main.mapsizey - total_height) / 2 global inv_canvas_width global inv_canvas_height inv_canvas_width = (g.tilesize * inv_width) + ((inv_width + 1) * 2) + 1 inv_canvas_height = (g.tilesize * inv_height) + ((inv_height + 1) * 2) + 1 start_x = (g.tilesize * main.mapsizex) / 2 start_y = (g.tilesize * main.mapsizey - total_height) / 2 #Create the main inv box. #The +20 is just "wiggle room", to prevent the length of the name #affecting the dimensions. g.create_norm_box( (base_x, base_y), ((g.tilesize * main.mapsizex) / 2 + g.hpbar_width + 15 - base_x, (g.tilesize * main.mapsizey + total_height) / 2 - base_y)) global curr_item curr_item = 0 #Set current window to inventory g.cur_window = "inventory" temp_width = g.hpbar_width * player.ep / player.adj_maxep if temp_width < 0: temp_width = 0 #Create the labels to the right: tmp_width = 52 label_start = ((g.tilesize * main.mapsizex) / 2 + tmp_width, (g.tilesize * main.mapsizey - total_height) / 2) text = g.name_name + ":" g.print_string(g.screen, text, g.font, (label_start[0], label_start[1] + 5), align=2) text = g.hp_name + ":" g.print_string(g.screen, text, g.font, (label_start[0], label_start[1] + 22), align=2) text = g.ep_name + ":" g.print_string(g.screen, text, g.font, (label_start[0], label_start[1] + 39), align=2) text = g.attack_name + ":" g.print_string(g.screen, text, g.font, (label_start[0], label_start[1] + 55), align=2) text = g.defense_name + ":" g.print_string(g.screen, text, g.font, (label_start[0], label_start[1] + 70), align=2) text = g.gold_name + ":" g.print_string(g.screen, text, g.font, (label_start[0], label_start[1] + 85), align=2) text = g.level_name + ":" g.print_string(g.screen, text, g.font, (label_start[0], label_start[1] + 100), align=2) text = g.exp_name + ":" g.print_string(g.screen, text, g.font, (label_start[0], label_start[1] + 115), align=2) #bindings menu_bind_keys() refresh_menu_buttons() refresh_stat_display() while 1: pygame.time.wait(30) g.clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: if menu_key_handler(event.key) == 1: return elif event.type == pygame.MOUSEMOTION: menu_mouse_move(event.pos) elif event.type == pygame.MOUSEBUTTONDOWN: if menu_mouse_click(event.pos) == 1: return tmpjoy = g.run_joystick() if tmpjoy != 0: if tmpjoy != g.bindings["left"] and tmpjoy != g.bindings["right"]: if menu_key_handler(tmpjoy) == 1: return