def __init__(self, game): self.game = game self.field = sprite.Sprite( pyglet.image.load(os.path.join(SPRITES_DIR, 'field.png')).get_texture()) self.field.opacity = options['VOF_opacity'] self.field.scale_x = window.width / self.field.image.width self.field.scale_y = window.height / self.field.image.height self.light = sprite.Sprite( pyglet.image.load(os.path.join(SPRITES_DIR, 'light.png')).get_texture()) self.light.scale_x = self.light.scale_y = 200 / self.light.image.height self.light_size = (self.light.width, self.light.height) self.fear_text = text.new(FONT, 20, u'FEAR') self.map_texture = {} self.tile_sprite = {} self.camera_group = camera.CameraGroup(self.game.camera) options.push_handlers(self) window.push_handlers(self) self.game.push_handlers(self)
def __init__(self): self.music_player = None self.current_music = None self.sound_playing = set() self.music_dict = load_all_music() self.sound_dict = load_all_sounds() options.push_handlers(self)
def enabled(self, enabled): if enabled == self._enabled: return self._enabled = enabled if enabled: window.push_handlers(self) options.push_handlers(self) for control in self.controls.itervalues(): control.enabled = True self.arrange_buttons() else: for control in self.controls.itervalues(): control.enabled = False window.remove_handlers(self) options.remove_handlers(self)
def __init__(self, game): self.game = game self.field = sprite.Sprite(pyglet.image.load(os.path.join(SPRITES_DIR, 'field.png')).get_texture()) self.field.opacity = options['VOF_opacity'] self.field.scale_x = window.width / self.field.image.width self.field.scale_y = window.height / self.field.image.height self.light = sprite.Sprite(pyglet.image.load(os.path.join(SPRITES_DIR, 'light.png')).get_texture()) self.light.scale_x = self.light.scale_y = 200 / self.light.image.height self.light_size = (self.light.width, self.light.height) self.fear_text = text.new(FONT, 20, u'FEAR') self.map_texture = {} self.tile_sprite = {} self.camera_group = camera.CameraGroup(self.game.camera) options.push_handlers(self) window.push_handlers(self) self.game.push_handlers(self)
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
def create_handlers(self): options.push_handlers(self) super(OptionsMenuToggleCheckBox, self).create_handlers()