Changeset 141


Ignore:
Timestamp:
06/15/09 12:16:41 (10 years ago)
Author:
maximinus_parpg
Message:

One final tweak to the internal walls.
Epydoc'd world.py and sound.py.

Location:
trunk/PARPG
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/objects/ground/walls/wall_rear/wall-top.xml

    r139 r141  
    11<?fife type="object"?> 
    22<object id="wall-rear-top" namespace="PARPG" blocking="1" static="1"> 
    3         <image source="wall-top.png" direction="0" y_offset="-25"/> 
     3        <image source="wall-top.png" direction="0" y_offset="-26"/> 
    44</object> 
  • trunk/PARPG/scripts/sounds.py

    r140 r141  
    2020class SoundEngine: 
    2121    def __init__(self, fife_engine): 
     22        """Initialise the SoundEngine instance 
     23           @type fife_engine: fine.Engine 
     24           @param fife_engine: Instance of the Fife engine 
     25           @return: None""" 
    2226        self.engine = fife_engine 
    2327        self.sound_engine = self.engine.getSoundManager() 
     
    2933     
    3034    def playMusic(self, sfile = None): 
     35        """Play music, with the given file if passed 
     36           @type sfile: string 
     37           @param sfile: Filename to play 
     38           @return: None""" 
    3139        if(sfile != None): 
    3240            # setup the new sound 
     
    3947 
    4048    def pauseMusic(self): 
    41         """Stop current playback""" 
     49        """Stops current playback 
     50           @return: None""" 
    4251        if(self.music_init == True): 
    4352            self.music.pause() 
     
    4554 
    4655    def toggleMusic(self): 
     56        """Toggle status of music, either on or off 
     57           @return: None""" 
    4758        if((self.music_on == False)and(self.music_init == True)): 
    4859            self.playMusic() 
     
    5162 
    5263    def setVolume(self, volume): 
     64        """Set the volume of the music 
     65           @type volume: integer 
     66           @param volume: The volume wanted, 0 to 100 
     67           @return: None""" 
    5368        pass 
    5469 
  • trunk/PARPG/scripts/world.py

    r140 r141  
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    18 import fife 
    19 import time 
     18import fife, time 
    2019from datetime import date 
    2120from scripts.common.eventlistenerbase import EventListenerBase 
     
    2524from sounds import SoundEngine 
    2625from settings import Setting 
    27 from scripts import inventory 
    28 from scripts import hud 
     26from scripts import inventory, hud 
    2927from scripts.context_menu import ContextMenu 
    3028from pychan.tools import callbackWithArguments as cbwa 
     
    4139 
    4240class Map(fife.MapChangeListener): 
     41    """Map class used to flag changes in the map""" 
    4342    def __init__(self, fife_map): 
    4443        fife.MapChangeListener.__init__(self) 
     
    5049    def __init__(self, engine): 
    5150        """Constructor for engine 
    52            TODO: Comment these variables""" 
     51           @type engine: fife.Engine 
     52           @param engine: A fife.Engine instance 
     53           @return: None""" 
    5354        super(World, self).__init__(engine, regMouse = True, regKeys = True) 
    5455        # self.engine is a fife.Engine object, not an Engine object 
     
    8081 
    8182    def reset(self): 
    82         """Reset the map to default settings""" 
     83        """Reset the data to default settings. 
     84           @return: None""" 
    8385        # We have to delete the map in Fife. 
    8486        # TODO: I'm killing the PC now, but later we will have to save the PC 
     
    9698 
    9799    def load(self, filename): 
    98         """Load a map given the filename 
    99            TODO: a map should only contain static items and floor tiles 
    100            Everything else should be loaded from the engine, because it 
    101            is subject to change""" 
     100        """Load a map given the filename. 
     101           @type filename: string 
     102           @param filename: Name of map to load 
     103           @return: None""" 
    102104        self.reset() 
    103105        # some messy code to handle music changes when we enter a new map 
     
    117119            if(layer.getId()[:size] == 'TransitionLayer'): 
    118120                self.transitions.append(self.map.getLayer(layer.getId())) 
    119  
    120121        # init the camera 
    121122        for cam in self.view.getCameras(): 
     
    125126        self.cord_render = self.cameras['main'].getRenderer('CoordinateRenderer') 
    126127        self.outline_render = fife.InstanceRenderer.getInstance(self.cameras['main']) 
    127          
    128128        # set the render text 
    129129        rend = fife.FloatingTextRenderer.getInstance(self.cameras['main']) 
    130130        text = self.engine.getGuiManager().createFont('fonts/rpgfont.png', 
    131                                                           0, str(TDS.readSetting("FontGlyphs", strip=False))) 
     131                                                       0, str(TDS.readSetting("FontGlyphs", strip=False))) 
    132132        rend.changeDefaultFont(text) 
    133133        # start playing the music 
     
    140140 
    141141    def addPC(self, agent): 
    142         """Add the player character to the map""" 
     142        """Add the player character to the map 
     143           @type agent: Fife.instance 
     144           @param : The object to use as the PC sprite 
     145           @return: None""" 
    143146        # actually this is real easy, we just have to 
    144147        # attach the main camera to the PC 
     
    146149 
    147150    def addObject(self, xpos, ypos, gfx, name): 
    148         """Add an object or an NPC to the map 
    149            It makes no difference to fife which is which""" 
     151        """Add an object or an NPC to the map. 
     152           It makes no difference to fife which is which. 
     153           @type xpos: integer 
     154           @param xpos: x position of object 
     155           @type ypos: integer 
     156           @param ypos: y position of object 
     157           @type gfx: string 
     158           @param gfx: name of gfx image 
     159           @type name: string 
     160           @param name: name of object 
     161           @return: None""" 
    150162        obj = self.agent_layer.createInstance( 
    151163                self.model.getObject(str(gfx), "PARPG"), 
     
    157169 
    158170    def displayObjectText(self, obj, text): 
    159         """Display on screen the text of the object over the object""" 
     171        """Display on screen the text of the object over the object. 
     172           @type obj: fife.instance 
     173           @param obj: object to draw over 
     174           @type text: text 
     175           @param text: text to display over object 
     176           @return: None""" 
    160177        obj.say(str(text), 1000) 
    161178 
    162179    def refreshReadyImages(self): 
    163         """Make the Ready slot images on the HUD be the same as those on the inventory""" 
     180        """Make the Ready slot images on the HUD be the same as those  
     181           on the inventory 
     182           @return: None""" 
    164183        self.setImages(self.hud.hud.findChild(name="hudReady1"), 
    165184                       self.inventory.inventory.findChild(name="Ready1").up_image) 
     
    172191 
    173192    def setImages(self, widget, image): 
    174         """Set the up, down, and hover images of an Imagebutton""" 
     193        """Set the up, down, and hover images of an Imagebutton. 
     194           @type widget: pychan.widget 
     195           @param widget: widget to set 
     196           @type image: ??? 
     197           @param image: image to use 
     198           @return: None""" 
    175199        widget.up_image = image 
    176200        widget.down_image = image 
     
    178202 
    179203    def closeInventoryAndToggle(self): 
     204        """Close the inventory screen. 
     205           @return: None""" 
    180206        self.inventory.closeInventory() 
    181207        self.hud.toggleInventory() 
     
    183209 
    184210    def displayInventory(self, callFromHud): 
    185         """Pause the game and enter the inventory screen 
    186            or close the inventory screen and resume the game 
    187            callFromHud should be set to true if you call this 
    188            function from the hud script""" 
     211        """Pause the game and enter the inventory screen, or close the 
     212           inventory screen and resume the game. callFromHud should be true 
     213           (must be True?) if you call this function from the HUD script 
     214           @type callFromHud: ??? 
     215           @param callFromHud: ??? 
     216           @return: None""" 
    189217        if (self.inventoryShown == False): 
    190218            self.inventory.showInventory() 
    191219            self.inventoryShown = True 
    192             if (callFromHud == False): 
    193                 self.hud.toggleInventory() 
    194220        else: 
    195221            self.inventory.closeInventory() 
    196222            self.inventoryShown = False 
    197             if (callFromHud == False): 
    198                 self.hud.toggleInventory() 
     223        if (callFromHud == False): 
     224            self.hud.toggleInventory() 
    199225 
    200226    # all key / mouse event handling routines go here 
    201227    def keyPressed(self, evt): 
    202         """When a key is pressed, fife calls this routine.""" 
     228        """Whenever a key is pressed, fife calls this routine. 
     229           @type evt: fife.event 
     230           @param evt: The event that fife caught 
     231           @return: None""" 
    203232        key = evt.getKey() 
    204233        keyval = key.getValue() 
     
    236265            self.sounds.toggleMusic() 
    237266 
    238     def getCoords(self, click): 
    239         """Get the map location x, y cords that have been clicked""" 
    240         coord = self.cameras["main"].toMapCoordinates(click, False) 
    241         coord.z = 0 
    242         location = fife.Location(self.agent_layer) 
    243         location.setMapCoordinates(coord) 
    244         return location 
    245  
    246267    def mousePressed(self, evt): 
    247         """If a mouse button is pressed down, fife calls this routine 
    248            Currently we assume this is on the map""" 
     268        """If a mouse button is pressed down, fife calls this routine. 
     269           @type evt: fife.event 
     270           @param evt: The event that fife caught 
     271           @return: None""" 
    249272        click = fife.ScreenPoint(evt.getX(), evt.getY()) 
    250273        if(evt.getButton() == fife.MouseEvent.LEFT): 
     
    278301                self.context_menu = ContextMenu(self.engine, data, pos) 
    279302 
    280     def placeHolderFunction(self): 
    281         """Just a simple function to make the PC say "Place Holder Function!" 
    282            It's in here because we needed some sort of function to test the context  
    283            menu with""" 
    284         self.agent_layer.getInstance("PC").say("Place Holder Function!", 1000) 
    285         self.context_menu.vbox.hide() 
    286         delattr(self, "context_menu") 
    287  
    288303    def mouseMoved(self, evt): 
    289         """Called when the mouse is moved""" 
     304        """Called when the mouse is moved 
     305           @type evt: fife.event 
     306           @param evt: The event that fife caught 
     307           @return: None""" 
    290308        click = fife.ScreenPoint(evt.getX(), evt.getY()) 
    291309        i=self.cameras['main'].getMatchingInstances(click, self.agent_layer) 
     
    305323            self.outline_render.removeAllOutlines() 
    306324 
    307     def toggle_renderer(self, r_name): 
    308         """Enable or disable the renderer named `r_name`""" 
     325    def placeHolderFunction(self): 
     326        """Just a simple function to make the PC say "Place Holder Function!" 
     327           It's in here because we needed some sort of function to test the 
     328           context menu with. 
     329           @return: None""" 
     330        self.agent_layer.getInstance("PC").say("Place Holder Function!", 1000) 
     331        self.context_menu.vbox.hide() 
     332        delattr(self, "context_menu") 
     333 
     334    def getCoords(self, click): 
     335        """Get the map location x, y cords from the screen co-ords 
     336           @type click: fife.ScreenPoint 
     337           @param click: Screen co-ords 
     338           @rtype: fife.Location 
     339           @return: The map co-ords""" 
     340        coord = self.cameras["main"].toMapCoordinates(click, False) 
     341        coord.z = 0 
     342        location = fife.Location(self.agent_layer) 
     343        location.setMapCoordinates(coord) 
     344        return location 
     345 
     346    def toggle_renderer(self): 
     347        """Enable or disable the grid renderer. 
     348           @return: None""" 
    309349        renderer = self.cameras['main'].getRenderer('GridRenderer') 
    310350        renderer.setEnabled(not renderer.isEnabled()) 
    311351 
    312352    def quitGame(self): 
    313         """Called when user requests to quit game 
    314            Just calls the ApplicationListener to do the quit""" 
     353        """Called when user requests to quit game. 
     354           TODO: Should give an 'Are you sure?' message 
     355           @return: None""" 
    315356        if(self.quitFunction != None): 
    316357            self.quitFunction() 
     
    318359    def pump(self): 
    319360        """Routine called during each frame. Our main loop is in ./run.py 
    320            We ignore this main loop (but FIFE complains if it is missing)""" 
     361           We ignore this main loop (but FIFE complains if it is missing).""" 
    321362        pass 
    322363 
Note: See TracChangeset for help on using the changeset viewer.