In an effort to speed up the development time of our little game, I fleshed-out the bare bones level editor into something a little more powerful and user friendly.
Before, objects were spawned in front of the player using the 0-9 number keys, numpad keys controlled object manipulation, and ‘/’ was used to select existing objects in front of the player so that they could be manipulated. It was awful.
Now there is a categorized left-hand sidebar that lists objects available to create. Because I chose to implement different objects with the same properties as a single class with enum values (instead of deriving multiple classes from a superclass), new types can be created and the menu is automatically populated by iterating through the enum of that type – this saves hard-coding new objects into the menu.
Furthermore, mouse input is now accounted for – click on the menu to select an object, click in the world to place it at that location. When an object is selected from the menu, ‘CREATE’ mode is activated so that every click places a new object. When no item is selected, ‘SELECT’ mode allows any object in the game world to be clicked on and set as the active instance for manipulation (or duplication).
Although it works well enough, the code itself is massive, messy, and inefficient. I can see the level editor turning into it’s own offshoot project in the future – a flexible, powerful, and user friendly editor that I can use with all my libgdx-based projects and perhaps something that even supports scripting events through the interface.
Below is a quick video of a stage I slapped together as a demonstration. Don’t mind the broken zombie AI and epileptic gates – there’ still a bug that causes newly created objects to misbehave, but when the level is reloaded everything works as it should.