Changeset 295


Ignore:
Timestamp:
10/01/09 07:13:39 (10 years ago)
Author:
eliedebrauwer
Message:

Ticket #103: Patch by Elie De Brauwer, Added possibility to make the player character run, this can be toggled with the run console command, comment[s:trac, t:103]

Location:
trunk/game/scripts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/console.py

    r281 r295  
    2525 
    2626        self.commands = [ 
    27             {"cmd":"exit"  ,"callback":self.handleQuit  ,"help":"Terminate application"}, 
    28             {"cmd":"grid"  ,"callback":self.handleGrid  ,"help":"Toggle grid display  "}, 
    29             {"cmd":"help"  ,"callback":self.handleHelp  ,"help":"Show this help string"}, 
    30             {"cmd":"load"  ,"callback":self.handleLoad  ,"help":"load directory file  "}, 
    31             {"cmd":"python","callback":self.handlePython,"help":"Run some python code "}, 
    32             {"cmd":"quit"  ,"callback":self.handleQuit  ,"help":"Terminate application"}, 
    33             {"cmd":"save"  ,"callback":self.handleSave  ,"help":"save directory file  "}, 
     27            {"cmd":"exit"  ,"callback":self.handleQuit  ,"help":"Terminate application "}, 
     28            {"cmd":"grid"  ,"callback":self.handleGrid  ,"help":"Toggle grid display   "}, 
     29            {"cmd":"run"   ,"callback":self.handleRun   ,"help":"Toggle player run/walk"}, 
     30            {"cmd":"help"  ,"callback":self.handleHelp  ,"help":"Show this help string "}, 
     31            {"cmd":"load"  ,"callback":self.handleLoad  ,"help":"load directory file   "}, 
     32            {"cmd":"python","callback":self.handlePython,"help":"Run some python code  "}, 
     33            {"cmd":"quit"  ,"callback":self.handleQuit  ,"help":"Terminate application "}, 
     34            {"cmd":"save"  ,"callback":self.handleSave  ,"help":"save directory file   "}, 
    3435        ] 
    3536        self.appListener=appListener 
     
    5455        self.appListener.world.activeMap.toggle_renderer('GridRenderer') 
    5556        return "Grid toggled" 
     57 
     58    def handleRun(self, command): 
     59        """ 
     60        Toggles run/walk mode of the PC player 
     61        @type command: string 
     62        @param command: The command to run. 
     63        @return: The response""" 
     64         
     65        if self.appListener.model.pc_run==1: 
     66            self.appListener.model.pc_run=0 
     67            return "PC is now walking" 
     68        else: 
     69            self.appListener.model.pc_run=1 
     70            return "PC is now running" 
     71             
    5672 
    5773    def handleHelp(self, command): 
     
    134150        return result  
    135151 
     152 
    136153    def handleConsoleCommand(self, command): 
    137154        """ 
  • trunk/game/scripts/engine.py

    r287 r295  
    5050        self.mapchange = False 
    5151        self.gameState = GameState() 
     52        self.pc_run = 1 
    5253 
    5354    def reset(self): 
     
    261262           @param position: Screen position of click 
    262263           @return: None""" 
    263         self.gameState.PC.run(position) 
     264        if(self.pc_run==1): 
     265            self.gameState.PC.run(position) 
     266        else: 
     267            self.gameState.PC.walk(position) 
    264268         
    265269    def changeMap(self, map, targetPosition): 
  • trunk/game/scripts/objects/actors.py

    r287 r295  
    122122     
    123123    def run(self, location): 
    124         """@type location: ??? 
    125            @param location: ??? 
     124        """Makes the PC run to a certain location 
     125           @type location: fife.ScreenPoint 
     126           @param location: Screen position to run to. 
    126127           @return: None""" 
    127128        self.state = _AGENT_STATE_RUN 
    128         self.behaviour.agent.move('run', location, self.behaviour.speed) 
    129          
     129        self.behaviour.agent.move('run', location, self.behaviour.speed+1) 
     130 
     131    def walk(self, location): 
     132        """Makes the PC walk to a certain location. 
     133           @type location: fife.ScreenPoint 
     134           @param location: Screen position to walk to. 
     135           @return: None""" 
     136        self.state = _AGENT_STATE_RUN 
     137        self.behaviour.agent.move('walk', location, self.behaviour.speed-1) 
     138       
    130139    def approach(self, location, action = None): 
    131140        """Approaches an npc and then ???. 
Note: See TracChangeset for help on using the changeset viewer.