Reference:Rio:world.py

From Post-Apocalyptic RPG wiki

Jump to: navigation, search

Code reference.png This article covers outdated code reference information!

Code reference articles are stored at the wiki for legacy reasons. They are often outdated and duplicate Epydoc code documentation and department-specific tutorials. Code reference articles need to be reviewed by the programming department to see if they provide any useful information that is not available elsewhere at the wiki. After they have been reviewed and their unique information has been moved to more appropriate articles, the code reference articles should be deleted.


MapListener Class

I haven't really poked around to infer what this class is supposed to be for (as it's not fully implemented), but I assume its for when the PC changes maps.

  • __init__()
  • onMapChanged()
  • onLayerCreate() - Not Implemented.
  • onLayerDelete() - Not Implemented.

World Class

The Rio de Hola World class inherits from the EventListenerBase class which provides an interface for listening for key and mouse events. The main loop for the game world is the pump() function which just handles how the cameras are handled due to recent events. While the main loop handles the cameras, most of the functionality is implemented in captured events.

  • __init__()
  • show_instancemenu()
    • Handles the display of the menu when you right click on an agent. This function will create and display a dropdown menu of all of the functions that the specific agent can handle.
  • hide_instancemenu()
    • Hides the dropdown menu.
  • reset()
    • Unloads the current map and all of its agents. The world class can then load in a new map + agents to be rendered.
  • load()
    • Takes the map defined in "filename" and loads it and all of the objects associated with that map. All agents and cameras are initialized. I assume this is supposed to load a game that was previously saved, but all it does is load a map from an XML file and initializes the game to the state saved in the map file.
  • save()
    • Saves the current configuration of the map. That's all it does at present. This function is supposed to save progress of the game (I presume), but instead only saves the map. That's kind of worthless to us, since we want to save the game state, not overwrite the map.
  • keyPressed()
    • Whenever a key is pressed this event handler method is passed an event that must be handled. Any keys not defined to be handled in this function will be ignored. Allows game functionality to be mapped to keys, e.g. i for inventory, or c for character sheet.
  • keyReleased()
    • When a key is released this function is called. If a key is not handled it will be ignored.
  • mouseWheelMovedUp()
    • When the mouse wheel is moved up this function is called. For now only camera zoom is handled while the CTRL key is held down, but any functionality can be mapped to this function.
  • mouseWheelMovedDown()
    • When the mouse wheel is moved down this function is called. For now only camera zoom is handled while the CTRL key is held down, but any functionality can be mapped to this function.
  • changeRotation()
    • Rotates the main camera 90 degrees counter-clockwise.
  • mousePressed()
    • When any mouse button is pressed, this function will be called. When the left mouse button is pressed, the PC is moved to the tile the mouse position denotes. The right mouse button will bring up a drop down menu that contain actions that can be executed on the agent/object by the PC. However, if a widget is underneath the mouse pointer (e.g. the options menu), the widget will capture the mousePressed() event and not the game world.
  • mouseMoved()
    • When the mouse moves, the event is handled by this function. At the moment, the only action that this function does is outline an agent in a defined list (in this case, only beekeeper and girl agents). However, it would be trivial to add some information on mouse over of an agent.
  • onConsoleCommand()
    • This function evaluates a python string passed to it by the IslandDemo Class for debugging purposes. You can bring up the console by pressing F10 in game.
  • moveButtonHandler()
    • Handles the event when you click on "Move here" in the drop down gui after you right click on an object.
  • talkButtonHandler()
    • Handles the event when you click on "Talk" in the drop down gui after you right click on an object.
  • kickButtonHandler()
    • Handles the event when you click on "Kick" in the drop down gui after you right click on an object.
  • kissButtonHandler()
    • Handles the event when you click on "Make out" in the drop down gui after you right click on an object.
  • inspectButtonHandler()
    • Handles the event when you click on "Inspect" in the drop down gui after you right click on an object. At the moment this is a debugging function to determine that objects are being initialized/created correctly.
  • pump()
    • This is the main loop for the game world. In this function, the cameras are readjusted based on new events since the previous pump() function call. For example, if the mousePressed() event was evoked because the user left clicked on a tile, the camera would follow the PC based on the PC's action stack.
Personal tools