def __init__(self): ShowBase.__init__(self) blenderpanda.init(self) self.input_mapper = inputmapper.InputMapper( os.path.join(CONFIG_ROOT_DIR, 'input.conf')) self.accept('quit', sys.exit) self.disableMouse() winprops = self.win.get_properties() self.win.move_pointer(0, winprops.get_x_size() // 2, winprops.get_y_size() // 2) winprops = p3d.WindowProperties() winprops.set_mouse_mode(p3d.WindowProperties.M_confined) self.win.request_properties(winprops) self.current_state = gamestates.MainState() def update_gamestate(task): self.current_state.update( p3d.ClockObject.get_global_clock().get_dt()) return task.cont self.taskMgr.add(update_gamestate, 'GameState')
def __init__(self): ShowBase.__init__(self) blenderpanda.init(self) self.accept('escape', sys.exit) self.disableMouse() self.inputmapper = InputMapper('config/input.conf') # Setup ECS self.ecsmanager = ECSManager() systems = [ components.CharacterSystem(), components.Camera3PSystem(), components.PhysicsSystem(), ] for system in systems: self.ecsmanager.add_system(system) #systems[-1].set_debug(self.render, True) self.template_factory = components.TemplateFactory(self.ecsmanager) def run_ecs(task): self.ecsmanager.update(globalClock.get_dt()) return task.cont self.taskMgr.add(run_ecs, 'ECS') # Setup initial game state self.game_state = GameState() def run_gamestate(task): self.game_state.update(globalClock.get_dt()) return task.cont self.taskMgr.add(run_gamestate, 'GameState')
def __init__(self): self.cvMgr = ConfigVariableManager.getGlobalPtr() load_prc_file_data('', 'textures-power-2 none') super().__init__() blenderpanda.init(self) self.accept('escape', sys.exit) if logger.isEnabledFor(logging.DEBUG): self.accept('d', self.toggle_debug_tools) for scene in scenes.available_scenes: self.addScene(scene()) # - surfdog - self.addScene(Scene('surfdog', filename='surfdog', # - surfdog - scale=[5.0, 0.1, 5.0], # - surfdog - position=[-8, 22, -2] # - surfdog - )) # -cannon- self.addScene(Scene('cannon', filename='cannon', # -cannon- position=[0,22,0], # -cannon- hpr=[-45,0,0] # -cannon- )) self.load_registered_scenes() # setup Horizons self.horizon = 'skysphere' self.addHorizon(Background('skysphere', filename='skysphere_mk2.egg')) self.addHorizon(Background('skybox', filename='skybox_1024')) self.load_horizon(self.horizon) self.console = ConsoleWindow(self) # explicit first hide self.console.toggleConsole(hide=True) self.setControls() self.render.set_shader_auto() atexit.register(self.killRestServer)
def __init__(self): ShowBase.__init__(self) blenderpanda.init(self) self.accept('escape', sys.exit) shader = p3d.Shader.load( p3d.Shader.SL_GLSL, vertex='phong.vert', fragment='phong.frag', ) self.render.set_shader(shader) # Scene Setup scene = self.loader.load_model('happy.bam') self.happy = scene.find('happy') scene.reparent_to(self.render) taskMgr.add(self.rotate_happy_task, 'Why is the room spinning?') fafnir.init(scene, self.render)
def __init__(self): ShowBase.__init__(self) blenderpanda.init(self) base.disableMouse() self.accept('quit', sys.exit) self.inputmapper = InputMapper('config/input.conf') self.save_data = None self.auto_save = False self.current_state = None self.change_state(gamestates.TitleState) def run_state(task): if self.current_state: self.current_state.run(globalClock.get_dt()) return task.cont self.taskMgr.add(run_state, 'Game State')
def __init__(self): ShowBase.__init__(self) blenderpanda.init(self) self.accept('escape', sys.exit) self.setup_fafnir() # Scene Setup scene = self.loader.load_model('happy.bam') self.happy = scene.find('happy') if hasattr(self, 'fafnir_np'): scene.reparent_to(self.fafnir_np) self.node_paths = self.fafnir_np.find_all_matches('**/+GeomNode') self.material_list = self.fafnir_np.find_all_materials() self.mesh_cache.update(self.node_paths) self.mesh_cache.bind(self.fafnir_np) self.material_cache.update(self.material_list, self.node_paths) self.mesh_cache.bind(self.fafnir_np) # win_width = self.win.get_x_size() # win_height = self.win.get_y_size() # self.draw_manager.update(len(self.material_list), win_width, win_height) else: scene.reparent_to(self.render) taskMgr.add(self.rotate_happy_task, 'Why is the room spinning?')
def __init__(self): ShowBase.__init__(self) blenderpanda.init(self) self.accept('escape', sys.exit)