26 March 2013 – Editor is finally wrapping up!
Today, I worked on the editor A LOT!
It does not seem like much to some experienced programmers, but the sheer amount of logic and programming necessary to make this work is just tremendous to me.
The above screenshot is the level editor in action. I created some tiles and blocks.
Using arrays to store the x,y coordinates (FlxPoint) of every object in the game, I save the data into arrays, such as playerArrays, exitArray, keysArray, and such.
The editor is also smart in the sense that when you place spikes, they “stick” to platforms in the correct direction. This was accomplished a long time ago, but I thought I should bring it up too. I coded the new “friends” button today, which allows you to place friends on the map. This is easy compared to the blocks, which I had spent hours trying to figure out how to get it to work.
Each key unlocks a specific set of blocks. To save this information, I created an array, of an array, of points, of blocks! And finally, I managed to get the blocks to be “saved” and exported into an actual, playable level!
Before I got this to work, I spent hours trying to make the blocks export properly and showing up, and then making sure that they are able to be exported back into the level editor when the player is done playing his level.
And when you return to the level editor, it re-imports the data back into the level editor. Theoretically, the player could close the game, re-launch the game, and his level will STILL be there! This is a new milestone accomplished. I shall celebrate by sleeping, because it is 8.29AM now and I was up all night fixing the level editor and getting it to work.
After today, I understand arrays a lot better.
I drew a hammer that can be used in the editor to destroy unwanted objects as well.
It replaces the old destroy button graphic.
Other Editor improvements/changes:
player2 can now be created in the Editor and interacts with player1 correctly (able to switch characters, collide, etc)
Updated the instructions panel
Editor now has a background that is in sync with the platform tiles’ type
Added UI to the editor’s playable level, as well as zoom feature as well
Copied a lot of game mechanics into the editor’s playable level (such as ability to collect friends, grow, interact with keys and collide with blocks)
New task to do:
Possibly add a kind of save and load system where the player can create more than one level in the editor, export them and re-edit any one of the exported levels at any time. I will not be touching the editor so soon, so this is probably not going to happen till I develop the other areas of the game further.
For those who want to somehow see my messy messy code: