Debug Mode


So, about 1/2 way through building the engine I decided to add in a debug mode, and it was probably the best thing I created so far, as far as helper tools are considered. What is this mess, in debug mode? Well, it's great for me because it tells me a ton. For one, all those white blocks are the collision rectangles. Each object gives its x/y coordinates above their heads. It tells me what map I'm currently on, the player's health (a number between 0 and 1), what tile position the player is at, the window size, what the weather is (Sunny, here), the playtime, what time of day it is in game (morning here), how many magic points and any results from the debug console.

The debug console rocks. I've only got two functions that it uses, but it is insanely helpful for looking into variables on the fly and in game. It's just:

debug:clear()

Which clears the debug console itself (but not any of the other debug tools like printing the name of the map, etc, just the console output) and-

debug:bug(string)

This basically takes a formatted string which can be variables of any sort. It can be called a bunch of times, and the console autostacks the results until clear() is called, when it clears that portion of the screen. SUPER HANDY. It lets be track down errors and issues crazyquick and make quick adjustments on the fly to test any fixes. This thing is a lifesaver and a timesaver, esp when I was working on the weather effects and the time of day changes. It took me maybe two hours to code it, and it was worth every second. It's easy to extend and add more debug output, and I can switch to debugmode with a press of a button (keyboard or joystick). It's also easy to leave out, just don't include() that library, and it won't be included at all. Perfect for final builds and sending them out to players.

Nice thing is, in debugmode, if you bring up the in game menu by pressing escape/start, it adds some functions you can call to test things out quickly. Like weather effects, fast forward time of day, freeze enemy movements, etc.

One hell of a great tool.

Get Emberglass

Buy Now$5.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.