Changeset 54


Ignore:
Timestamp:
05/08/09 14:54:53 (11 years ago)
Author:
maximinus_parpg
Message:

Set Model / View data model for PARPG.
Code no longer looks like Rio demo.
Started to split map from objects.
Added crate and NPC character.

Location:
trunk/PARPG
Files:
12 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/maps/map.xml

    r52 r54  
    11<?xml version="1.0" encoding="ascii"?> 
    22<map id="my-map" format="1.0"> 
     3    <!-- Firstly import all the gfx objects we need for this map --> 
    34        <import file="../objects/agents/player/player.xml"></import> 
     5        <import file="../objects/agents/npcs/npc_woman/npc-woman.xml"></import> 
    46        <import file="../objects/ground/grass/grass-a.xml"></import> 
    57        <import file="../objects/ground/grass/grass-b.xml"></import> 
     
    79        <import file="../objects/ground/brick/brick.xml"></import> 
    810        <import file="../objects/ground/block/block.xml"></import> 
    9          
     11        <!-- import the buildings --> 
    1012        <import file="../objects/buildings/building1/building1.xml"></import> 
    1113        <import file="../objects/buildings/building2/building2.xml"></import> 
    1214        <import file="../objects/buildings/building3/building3.xml"></import> 
    13                  
     15        <!-- Import the tile transition tiles --> 
    1416        <import file="../objects/ground/grass/transition/grass-tc01.xml"></import> 
    1517        <import file="../objects/ground/grass/transition/grass-tc02.xml"></import> 
     
    10511053        <layer x_offset="0.0" pathing="cell_edges_and_diagonals" y_offset="0.0" grid_type="square" id="ObjectLayer" x_scale="1" y_scale="1" rotation="0.0"> 
    10521054                <instances> 
    1053                         <i x="0.0" o="boy" y="0.0" r="0" id="PC" z="0.0"></i> 
     1055                    <i x="0.0" o="boy" y="0.0" r="0" id="PC" z="0.0"></i> 
    10541056                <i x="8.0" o="block" z="0.0" y="-12.0" r="0"></i> 
    10551057                        <i x="9.0" o="block" z="0.0" y="-12.0" r="0"></i> 
  • trunk/PARPG/run.py

    r48 r54  
    2323import fife, fifelog 
    2424from scripts import world 
     25from scripts import engine 
    2526from scripts.common import eventlistenerbase 
    2627from basicapplication import ApplicationBase 
     
    5556 
    5657class PARPG(ApplicationBase): 
    57     """Main Application class""" 
     58    """Main Application class 
     59       We use an MV data model. 
     60       self.world is our view 
     61       self.engine is our model""" 
    5862    def __init__(self): 
    5963        super(PARPG,self).__init__() 
    6064        self.world = world.World(self.engine) 
     65        self.model = engine.Engine(self.world) 
    6166        self.listener = ApplicationListener(self.engine, self.world) 
    62         self.world.load(str(TDS.readSetting("MapFile"))) 
     67        self.model.loadMap(str(TDS.readSetting("MapFile"))) 
    6368 
    6469    def loadSettings(self): 
  • trunk/PARPG/scripts/agents/agent.py

    r30 r54  
     1#!/usr/bin/python 
     2 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
     17 
    118import fife 
    219 
     
    825        self.agentName = agentName 
    926        self.layer = layer 
    10         if uniqInMap: 
     27        if(uniqInMap==True): 
    1128            self.agent = layer.getInstance(agentName) 
    1229            self.agent.addActionListener(self) 
     
    1936        """Called when agent first used - normally overridden""" 
    2037        print "No start defined for Agent" 
     38 
  • trunk/PARPG/scripts/world.py

    r48 r54  
    2020from loaders import loadMapFile 
    2121from agents.hero import Hero 
     22from agents.npc import NPC 
    2223from settings import Setting 
    2324 
     
    3940        pass 
    4041 
     42class Map: 
     43    def __init__(self,fife_map): 
     44        self.listener=MapListener 
     45        self.map=fife_map 
     46     
     47    def addPC(self,pc): 
     48        pass 
     49     
     50    def addNPC(self,pc): 
     51        pass 
     52 
    4153class World(EventListenerBase): 
    4254    """World holds the data needed by fife to render the engine 
    43        Extracting information from the map file, such as is there an object 
    44        here, and so forth are normally done from here, so I propose this 
    45        acts as the map class 
    46        Presumably the story engine will need access to this class""" 
     55       The engine keeps a copy of this class""" 
    4756    def __init__(self, engine): 
    4857        super(World, self).__init__(engine, regMouse=True, regKeys=True) 
     
    5463        self.instance_to_agent = {} 
    5564        self.transitions = [] 
     65        self.PC=None 
     66        self.npcs=[] 
    5667 
    5768    def reset(self): 
     
    6576 
    6677    def load(self, filename): 
    67         """Load a map given the filename""" 
     78        """Load a map given the filename 
     79           TODO: a map should only contain static items and floor tiles 
     80           Everything else should be loaded from the engine, because it 
     81           is subject to change""" 
    6882        self.filename = filename 
    6983        self.reset() 
     
    7993            if(layer.getId()[:size]=='TransitionLayer'): 
    8094                self.transitions.append(self.map.getLayer(layer.getId())) 
     95 
     96        # init the camera 
     97        for cam in self.view.getCameras(): 
     98            self.cameras[cam.getId()] = cam 
     99        self.view.resetRenderers() 
     100        self.target_rotation = self.cameras['main'].getRotation() 
     101        self.cord_render=self.cameras['main'].getRenderer('CoordinateRenderer') 
     102 
     103    def addPC(self,xpos,ypos): 
     104        """Add the player character to the map 
     105           The id we use is always is always PC""" 
     106        # first we need to add the PC as an object on the map 
    81107        self.PC = Hero(self.model,'PC',self.agentlayer) 
    82108        self.instance_to_agent[self.PC.agent.getFifeId()] = self.PC 
    83109        # ensure the PC starts on a default action 
    84110        self.PC.start() 
     111        # attach the main camera to the PC 
     112        self.cameras['main'].attach(self.PC.agent) 
     113     
     114    def addNPC(self): 
     115        """Add a non=player character to the map""" 
     116        pass 
     117     
     118    def addObject(self): 
     119        """Add an object to the map""" 
     120        pass 
    85121 
    86         # init the camera 
    87         for cam in self.view.getCameras(): 
    88             self.cameras[cam.getId()] = cam 
    89         self.cameras['main'].attach(self.PC.agent) 
    90         self.view.resetRenderers() 
    91         self.target_rotation = self.cameras['main'].getRotation() 
    92         self.cord_render=self.cameras['main'].getRenderer('CoordinateRenderer') 
    93  
     122    # all key / mouse event handling routines go here 
    94123    def keyPressed(self, evt): 
    95124        """When a key is depressed, fife calls this routine.""" 
     
    122151 
    123152    def pump(self): 
    124         """Routine called during each frame. Here we need to call the 
    125            story engine code""" 
     153        """Routine called during each frame. Our main loop is in ./run.py 
     154           We ignore this main loop (but FIFE complains if it is missing)""" 
    126155        pass 
    127156 
  • trunk/PARPG/settings.xml

    r26 r54  
    1414        <FontGlyphs> abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&amp;`'*#=[]\"</FontGlyphs> 
    1515        <LogModules> controller </LogModules> 
    16         <LogToPrompt> 1 </LogToPrompt> 
     16        <LogToPrompt> 0 </LogToPrompt> 
    1717        <LogToFile> 0 </LogToFile> 
    1818        <ImageChunkSize> 256 </ImageChunkSize> 
Note: See TracChangeset for help on using the changeset viewer.