Update #21 - Object Editor

Friday, June 3rd. Nothing bizarre to report.

  • Improved the TileMap and MapParser.
  • Added some output classes, like "ParseEdit" and "Repeater".

Object Editor

Even though the majority of my time this week was spent on the object editor, it's very well done and will increase my map-creating productivity. It's worth mentioning that only level designers will be using this, so you don't have to worry too much about this. This may be a bit too boring for my non-technical readers. Alright, there are three important areas I'll cover: ButtonsParsing, and Editing.


The buttons on the far left can be described easily as three different types:

  1. Move All Objects
  2. Filter Objects
  3. Hide/Show Object Window

The "Move Left", "Move Right", "Move Up", "Move Down" buttons do as it implies. This will move all objects one tile towards the respective direction. The "Filter Objects" buttons will show or hide the respective object types. Lastly, the "Hide/Show Object Window" button should be self-explanatory.

Object Parsing

To add in an object, the user must first select the category they want to use. These categories are chosen using the left and right arrow keys (top-right), and include names like "Sensors", "Logic", "Flora", "Items", etc. You'll see all of the possible choices in the top-right window. As you start typing a name in the bottom box, the window acts as an auto-suggestion similar to search engines. This will filter out objects that don't start with the letters that are being typed.

Next, type in the variables in the expected format and hit the enter key to send the text to be parsed. If it is successful, your object will be added to the game world. Here is an example of valid text format for SkillSensor:

SkillSensor 50 1000 1000 51 Health 10 100

Following the Object Window, you can see this will add in a "SkillSensor" object with an ID of 50, a position of x1000 y1000, a TriggerID of 51, "Health" as the targeted skill, and a level range of 10 - 100. If a monster or player activates a trigger with an ID that equals the above triggerID, and their health level is greater than or equal to 10 and less than 100, the SkillSensor object will be be "on". With this, a door can only be opened when the player has a skill level greater than or equal to "10".

Of course, there are simpler objects that can be parsed. Adding in items is relatively simple and self-explanatory, once you look at the required variables and order.

Four different trigger and sensor layouts.

Four different trigger and sensor layouts.

Object Editing

An example of the object's variables you can edit.

An example of the object's variables you can edit.

Editing an object is similar to adding one. First, you must select an object by clicking on the object's box, and it's box will colored white. Once you have an object selected, hovering over the object's box will show you all of your options, including changing variables or calling void methods. Then, just type in the name of the variable (usually after an int, string, Point, Vector2, etc), followed by the new value.

It's also worth noting that I added a class called "ParseEdit", which uses the same methods that object editing does. The difference is it can be activated with a trigger. It's very powerful, and I look forward to using it too much.

Variable Injection

Imagine you are adding in an object which follows this variable format:

Object int ID, Texture2D Image, Point TileLocation, Vector2 Offset

There are quite a few things here that most of us (yes, even me) wouldn't know or be able to remember:

  • Texture2D Image. The path of the image file relative to the executable directory. Finding the valid path and typing it out is... impractical.
  • Point TileLocation. The location of the tile the object will be on. This is easier to get, but still a tad inconvenient.
  • Vector2 Offset. The offset location of the object, relative to the tile. This may be confusing to some.

When typing the text to be parsed, it could end up looking something like this:

Object 25 MapContent/Tileset/Object/Switches/On/springButton.xnb 27 43 20 65

That's no fun, especially the .xnb path which can be different for every content file. Instead of typing this by yourself, I've added in some convenient words that are automatically changed to the right value:

  • TileX. Horizontal tile position of the mouse.
  • TileY. Vertical tile position of the mouse.
  • OffsetX. Horizontal offset of the mouse, relative to the current tile. Value between 0 and 128.
  • OffsetY. Vertical offset of the mouse, relative to the current tile. Value between 0 and 128.
  • MsX. Horizontal position of the mouse. Measured in the game world pixels, not screen pixels.
  • MsY. Vertical position of the mouse. Measured in the game world pixels, not screen pixels.
  • Texture. Opens a dialogue box, allowing you to browse to the location of a valid .xnb content file.

Now the parsed text can look like this:

Object 25 texture tilex tiley offsetx offsety

This is shorter, which means less finger cramps and time spent! The Texture is definitely the major time-saver here. Now, I would have preferred to be able to load real images files, like .png, .bmp, or .jpg, though it wouldn't allow it unfortunately.

I was surprised how long the object editor took! My general rule for log posts is I should have at least two or three major talking points. I'm so glad I didn't put this post off until next week, because it would have been a bit too large. Not sure what I'll work on next week. I'll see what I feel I should be working on. Possibly AI work, since I really should get on that again.

If you have any ideas, constructive criticism, or just want to tell me how much you dislike my game, you can: Send me an email, tweet @TheShyyGuy, comment on the Facebook page, or respond here!

From Enckling, with love.
Shyy Guy