def go_to_map(self, m): if isinstance(m, maps.Map): _map = m else: # accept map name/index if m in self.map_dict.values(): _map = self.map_dict[m] else: _map = save_load.load_map(self, m) self.map_dict[m] = _map self.map = _map self.gather_objects() self.fears_dict = self.map.fears_dict
def __init__(self): Proxy.set_underlying_instance(gslib.game, self) TODO = [] TODO.append("character pathe-ing; then add a go_to function, include in idle_functions.patrol") TODO.append("optimize map drawing: combine all sky layers, combine all ground layers") TODO.append("optimize map drawing: use just one texture for all mid layer static_objects") TODO.append("optimize map drawing: batch static_objects") TODO.append("add character renaming/re-aging to map_edit") TODO.append("implement pyglet camera (include zoom!)") TODO.append("implement field of view slider (after pyglet camera implemented)") TODO.append("keybind menu in alphabetical order") TODO.append("design more sprites and make default characters (in character_objects)") TODO.append("add deletion of function choices to char edit - generally improve it") TODO.append("add players to saving - both save_map and save_state") TODO.append("better character function editor, specifically patrol path") TODO.append("activate() while possessed button") TODO.append("props that cant be possess-walked - can be picked up but cant pick up") TODO.append("chars that can pick props up - works in conjunction with flair (keep flair for particle effects)") self.TODO = TODO self.object_collision_lookup = collision.ObjectCollisionLookup(self) self.pathfinder = pathfinder.Pathfinder() self.camera_padding = (32, 32, 96, 32) # left right up down self._zoom = 1.0 self.camera = camera.Camera(x=0, y=0, zoom=self._zoom) # enable alpha-blending pyglet.gl.glEnable(pyglet.gl.GL_BLEND) pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE_MINUS_SRC_ALPHA) window.push_handlers(self) options.push_handlers(self) # TODO: why would we want this? #self.set_location(5, 30) # aligns window to top left of screen (on windows atleast) self.main_menu = menus.MainMenu(self, (161, 100)) self._state = STARTUP self.last_state = None self.movie_next = "default.mpg" self.movie_player = movie.MoviePlayer() self.game_running = True self.graphics = graphics.Graphics(self) self.sound_handler = sound.Sound() self.credits = credits.Credits() self.options_menu = menus.OptionsMenu(self, (200, 50)) self.game_over_screen = game_over_screen.GameOverScreen() self.players = {'player1': player.Player(self, TILE_SIZE * 6, TILE_SIZE * 2, 16, 16, 'GhostSheet.png'), 'player2': player.Player(self, 0, 0, 16, 16, 'TutorialGhost2.png')} self.skills_dict = skills.load_skill_dict() self.skill_menu = menus.SkillsMenu(self, (200, 150)) self.disp_object_stats = False self.object_stats = None # input controllers self.key_controller = key.KeyController(self) self.mouse_controller = mouse.MouseController(self) self.joy_controller = joy.JoyController(self) self.keybind_menu = menus.KeyBindMenu(self, (190, 40)) self.action_to_rebind = None self._map = None self.map_dict = {} # self.map_dict['level3'] = save_load.load_map(self, 'level3') # self.map_dict['level2'] = save_load.load_map(self, 'level2') # self.map_dict['martin'] = save_load.load_map(self, 'martin') # self.map_dict['boss1'] = save_load.load_map(self, 'boss1') self.map_dict['boss2'] = save_load.load_map(self, 'boss2') self.map_index = 'boss2' self.map = self.map_dict[self.map_index] self.game_buttons = { 'change_map': button.Button(function=self.change_map, pos=(0, 0), size=(20, 20), visible=True, text=u'M', border_color=(120, 50, 80), border_width=3, color=(120, 0, 0), window=window)} self.game_drop_lists = {} # self.toPossess = None self.selected_object = None self.world_objects_to_draw = [] self.screen_objects_to_draw = [] # self.objects = dict(self.objects.items() + self.map.objects.items()) self.show_fears = False self.show_ranges = False self.walrus = walrus.MetaWalrus() self.key_controller.load() self.touching = [] self.last_touching = [] self.editor = Editor(self) self.force_run_objects = False self.cursor = None self.new_trigger_capture = False self.objects = {} self.gather_objects() self.highlighted_control = "" self.fps_clock = pyglet.clock.ClockDisplay() self.ticks_clock = pyglet.clock.Clock() self.ticks_clock_display = pyglet.clock.ClockDisplay(format=' ticks:%(fps).2f', clock=self.ticks_clock) self.draw_clock = pyglet.clock.Clock() self.draw_clock_display = pyglet.clock.ClockDisplay(format=' fps:%(fps).2f', clock=self.draw_clock) pyglet.clock.schedule_interval(self.update, TICK_INTERVAL) self.sound_handler.play_music('2 ghost lane') self.message_box = None # If set, a message box taking all focus is being displayed. self.dialogue = None # If set, dialogue is being played. self.update_exception_hook = (None, None) self.state = MAIN_MENU self.fears_dict = self.map.fears_dict