Code Optimization: Debug Mode, Command Console and Edit Mode


This is the last part of the gamekit's engine before the last and final new gameplay features. Major overhauling improvements and changes were made to the technical and utility parts of the engine. Said improvements and changes concern debug mode and it's related accompanying features and functions.

With that done and putaway and the more difficult work like fetching variables en masse (and thus querying what their contents are, if anything) for the debug console saved for the very end of development, I can summarize what has changed, what I've learned as well as going over anything new or greatly changed as a result of the implementation, changes and fixes.

Both debug mode and the command console saw major changes, along with the introduction of the in-game edit mode that I mentioned ages ago. Debug mode may not get many more overly major changes but it's functionality is supplemented by the command console and the edit mode, especially for testing or debugging purposes.

Debug mode had only a handful of changes itself as it is not too chunky in terms of features or functionality but is still a moderately useful tool towards debugging and it's related functions. The feed of statistics and information with debug mode has not only been changed to a graphical sprite based font for readability's sake but has also been split in half and moved to accommodate not cluttering the screen's interface with too much info. I previously debated removing the ACT portion, but have kept it as since keeping a record of what the current key/gamepad press is vital for debug purposes. 

RAM and CPU have also been changed to display the proper values, concerning mb and CPU usage %, respectively. Additionally, debug mode has gained the ability to output the associated data for an object to the new debug console as well as toggle the visibility of bounding boxes for objects, whether all, visible objects or invisible objects, the latter intended for debugging purposes. This will also eventually include an object's instance variables but I will wait until the end of development, as I want to tidy up the objects in-game, delete unused ones, standardize variables, etc. Debug mode also now shows the MODE stat, which details what screen the game is set to, which is an in-game variable I use to restrict certain behaviors or actions.

The debug console now outputs to a command prompt based window, which reads from a sessionlog.txt file that the engine appends log messages to. As expected for debugging purposes, this new console saves backups per session and this is also now where debug commands feed out to, message wise. As another debugging tool, this debug console will also feed out any possible error messages, currently concerning data-sources for in-game hash-tables/arrays/etc failing to load or the game getting critical FPS performance issues (15 FPS or lower by default). Also, a bunch of new commands!

/boundboxes: Toggle flashing red bounding boxes for objects, can be set to all, invisible objects only, or visible objects only
/damage: Harms the player by the specified amount, up to 9. Two is one heart, four is two hearts and so forth.
/freecam: Enables freecam mode, allows free movement without any boundaries preventing movement, such as solid objects (thus, you can also go out of bounds)
/gamespeed: Changes gamespeed, arguments are 0, 0.5, 1, 1.5 and 2
/getdistance: Select two objects, prints out the distance between them in X/Y
/hud: Shows/hides the hud
/invisible: Makes it so that enemies that chase or have line-of-sight ignore the player
/killpickedobject: Destroys the object that the mouse is over


Lastly, the edit mode I spoke of a long time ago is now implemented. This can be only accessed via debug mode. Edit mode has the functionality to spawn, destroy and edit a pre-existing object's metadata (such as chest contents) on the fly without having to open or go back to Construct 2. This isn't meant as a full-on solution to map creation or game creation and serves more as a debug/testing tool like Sonic Mania's debug mode. Edit mode uses a right-click context menu that behaves differently on certain conditions, such as spawning the selected object on empty tiles, deleting objects (if an object is present on the 16x16 tile that the edit cursor is on) or editing an object's metadata if the cursor is over an existing object. 

There are also GUI buttons for objects (such as inventory) and clicking them will spawn a copy of the object that follows the mouse. Clicking objects with certain GUI-items will allow for certain interactions, such as using them to set a chest's contents easily or using a Lamp to light a torch. Further functionality planned is spawning enemies (as part of the increased object list) and more specific GUI-Item/Object interactions, such as locking dungeon doors.


Get A-RPG Gamekit

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.