Debugging games can be fun! Or not fun. Depends on what your definition of "fun" is.
Either way, starting with GameMaker: Studio, GameMaker has a proper debugger with breakpoints, step-by-step execution, watches, profiling, and other conveniences.
There is also an Output panel,
to which you can write messages using show_debug_message
.
This can be preferable if you need to inspect order of execution or are in a hurry -
after all, throwing a quick look on the panel is fast.
You know what's not fast though? Using show_debug_message
to do so.
2024 note: for current GameMaker versions there's a new version with file:line prefix!
Suppose you want to output the player's XY for something, like so
720, 42
That shouldn't take too long, we can just...
show_debug_message(string(x) + ", " + string(y));
That's a bit of boilerplate for just two values.
Granted, you can auto-complete some of it and skip on spaces, but still it's not that fast to type out, you know?
So, my smart planTM is that we get this little script going:
/// trace(...values) var r = string(argument[0]), i; for (i = 1; i < argument_count; i++) { r += ", " + string(argument[i]); } show_debug_message(r);
And then we can use it just like:
trace(x, y);
And that's a quarter of character count!
Could have been even shorter if the script was called log
,
though personally I'm not a fan of that
(when there are log2
/ log10
/ logn
math functions).
And if you'd like to see output for a compiled game, you can do that too if you run the executable from Command Prompt / PowerShell like this:
.\game.exe -output out.txt -debugoutput out.txt
And that's it!
Dude, I was just about to make my own logger, but while I was messing with GMlive.js I noticed tracer. Love it!
Me too! Another victim of yal’s dastardly bait-and-switch, promising one useful tool and hiding another one inside it.
This is great help. Thanks!
Your Smart Plan(TM) saves me a lot of time. Thank you!