Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

Assignment 2 – Level Editor Part 2

In this assignment you will extend your level editor to support more of the features of the game and implement saving and loading levels. Note that this assignment is deceptively difficult, especially the XML loading functionality. Be sure to give yourself plenty of time to complete it!  Specifically, you will: 

  • Add two classes to your project – GameCharacter and Item. Both classes have names and descriptions. A GameCharater can be one of three kinds – Player, Adult, or Child. Use an enum to store this value. An Item can have one or more of the following three actions associated with it: shake, throw, possess. Use three booleans to represent whether the Item has that action associated with it. 
  • Rooms may contain Items and GameCharacters, so add a way to store them to the Room class. 
  • Add functionality to your user interface to allow adding GameCharacters and Items to rooms. You may do this in any way you like, as long as there is a way to add more than one  GameCharacter / Item to a Room, and to select its appropriate characteristics without having the game in a bad state (e.g., a GameCharacter without a designation of the kind of GameCharacter it is). 
  • Add a menu bar to your level editor with a File menu. Your File menu should contain three items: Load, Save, and Quit. 
  • Implement simple quit functionality. You may wish to ask the user to save their file if they have not already.
  • Implement the Load functionality by implementing an XML SAX parser. See below for the file format specification. 
  • In each of your Room, GameCharacter, and Item classes implement a method called toXML which will produce a string representation of the XML for that particular room, character, or item. Your Room’s toXML should call the one for its containing items and characters. 
  • Implement the Save functionality using your toXML methods. Produce an error message if the game does not include one (and only one) Player, along with between 1 and 5 total adults and children.
  • Extensively test your code, a demo file may be used for you to test your loading functionality. Ensure your produced files work to load back into your editor. Also ensure they load cleanly into the game from last semester (see Assignment 1 for a link to download).

File specification: 

  • Root element: xml 
  • The root will contain one or more room elements which will have the following attributes:
    • name: the name of the room
    • description: the description of the room
    • xcoord: the x coordinate of the room on the grid
    • ycoord: the y coordinate of the room on the grid
    • north: the name of the room to the north. If none, do not include this attribute. 
    • south, east, west: analogous with north. 
  • A room may contain one or more items, and one or more characters. Character elements are named adult, child, or player depending on what kind it is. 
  • Items have the following attributes: 
    • name: the name of the item
    • description: the description of the item
    • actions: a comma separated list of the names of the actions the item has: shake, throw, or possess. 
  • Adult, child, and player elements have the following attributes: 
    • name: name of the character
    • description: the description of the character