def handle_events(): global see_right, skeletons, items, click, bonfire_ready, background, bonfire, light, stone, wood events = get_events() for event in events: if event.type == SDL_QUIT: game_framework.quit() elif event.type == SDL_MOUSEMOTION: mousecursor.position(x=event.x, y=VIEW_HEIGHT - 1 - event.y) elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: del (skeletons) del (items) del light game_framework.change_state(title_state) elif event.type == SDL_KEYDOWN and event.key == SDLK_p: game_framework.push_state(pause_state) elif event.type == SDL_MOUSEBUTTONDOWN and event.button == SDL_BUTTON_RIGHT: if collision(ui, mousecursor): if stone >= 2 and wood >= 2: game_world.remove_object(bonfire) game_world.remove_object(light) bonfire = Bonfire(player.x, player.y) game_world.add_object(bonfire, 3) bonfire.set_background(background) light = Light(bonfire.x, bonfire.y) game_world.add_object(light, 3) light.set_background(background) stone -= 2 wood -= 2 else: player.handle_event(event)