def pump(self, dt): """Routine called during each frame. Our main loop is in ./run.py""" # uncomment to instrument # t0 = time.time() if self.paused: return ControllerBase.pump(self, dt) PARPGWorld.pump(self, dt) self.updateMouse() if self.model.active_map: self.view.highlightFrontObject(self.last_mousecoords) self.view.refreshTopLayerTransparencies() self.handleScrolling() self.handleCommands()
def __init__(self, engine, view, model, application): """Construct a new L{CharacterCreationController} instance. @param engine: Rendering engine used to display the associated view. @type engine: L{fife.Engine} @param view: View used to display the character creation screen. @type view: L{ViewBase} @param model: Model of the game state. @type model: L{GameModel} @param application: Application used to glue the various MVC components together. @type application: L{fife.extensions.basicapplication.ApplicationBase}""" ControllerBase.__init__(self, engine, view, model, application) PARPGWorld.__init__(self, engine) self.settings = self.model.settings self.view.start_new_game_callback = self.startNewGame self.view.cancel_new_game_callback = self.cancelNewGame
def __init__(self, engine, view, model, application): ''' Constructor @param engine: Instance of the active fife engine @type engine: fife.Engine @param view: Instance of a GameSceneView @param type: parpg.GameSceneView @param model: The model that has the current gamestate @type model: parpg.GameModel @param application: The application that created this controller @type application: parpg.PARPGApplication @param settings: The current settings of the application @type settings: fife.extensions.fife_settings.Setting ''' ControllerBase.__init__(self, engine, view, model, application) PARPGWorld.__init__(self, engine) #setup functions for the GameEnvironment createItemByID = lambda identifier : ( self.model.createItemByID( identifier=identifier, world=self) ) createItemByType = lambda item_type, identifier: ( self.model.createItemByType( item_type=item_type, identifier=identifier, world=self) ) funcs = { "createItemByID": createItemByID, "createItemByType": createItemByType, } self.model.game_state.funcs.update(funcs) self.systems.scripting.game_state = self.model.game_state #this can be helpful for IDEs code analysis if False: assert(isinstance(self.engine, fife.Engine)) assert(isinstance(self.view, GameSceneView)) assert(isinstance(self.view, GameModel)) assert(isinstance(self.application, PARPGApplication)) assert(isinstance(self.event_manager, fife.EventManager)) # Last saved mouse coords self.action_number = 1 self.has_mouse_focus = True self.last_mousecoords = None self.mouse_callback = None self.original_cursor_id = self.engine.getCursor().getId() self.scroll_data = {"mouse":[], "kb":[], "offset":[0,0]} self.scroll_timer = extensions.fife_timer.Timer( 100, lambda: self.view.moveCamera(self.scroll_data["offset"]), ) #this is temporary until we can set the native cursor self.resetMouseCursor() self.paused = False if model.settings.get("fife", "PlaySounds"): if not self.view.sounds.music_init: music_path = 'music' music_file = random.choice( glob.glob('/'.join([music_path, '*.ogg'])) ) self.view.sounds.playMusic(music_file) self.initHud()