Tag Archives: code

Keyboard shortcuts info in debug builds – IMGUI style

I want to share a little discovery, a trick easing the creation and development of games. First a short motivational and historical introduction.

Case study

I don’t know if you have it too, but when I’m creating a game, I often add to it a lot of keyboard shortcuts – even a few dozens. Player avatar, enemies, map, camera, physics, rules etc. Shortcuts use normal letters, digits, F keys, special keys (tab, home, backspace), and their combinations with ctrl, shift, alt. Sometimes it’s hard to figure out what is available and what does what.

Especially I had problem with that in Ninja Cat, where shortcut availability depended on compilation mode (CONFIG:: variables, you can treat them like #defines) – debug+editor had all of them, debug without editor had a part of that, editor without debug had yet another part etc. It was very useful, because sometimes having too much shortcuts and special keys was bad – ie. during testing, when pressing some keys would change gameplay.

But I didn’t want to have it as binary – either all, or none. Sometimes the ability to intervene meant beaing able to catch a bug on the hot spot (perhaps Heisenbug?), and do something about it. So it was nice having it at such a granular level (debug/release, editor, deploy, profile). The disadvantage was that often I forgot what the actual shortctus were, what could I do at this moment. I was pressing shortcuts and they didn’t work, or I was forgeting about some magic functionality, hidden in not so visible code places.

Solution

Ok, now I’ll explain how to fix this situation. The easiest is to just display a list of all shortcuts, upon pressing some key like F1 or H(elp). But nobody would be able to create such list and maintain it over time. Also, having one huge list of shortcuts when you have only let’s say, a third of them, is not that really helpful. The solution? Do it in a automated way.
Read More…

Config::Toggle plugin for FlashDevelop

I am using FlashDevelop to code in AS3. It’s stable, quite feature complete and very lightweight – using it to develop Ninja Cat was pleasure. During that time I learned that it’s possible to create conditional compilation constants, so you can selectively include some pieces of code. Sounds complicated, but it’s just a simplified version of #ifdef macrodefinitions from C language. It’s a simple way of creating traditional debug/release versions of game, but you can also extend it to editor/stats/ads/portal specific versions.

Problem

Unfortunately editing those constants in FlashDevelop is time and labour intensive. If you want to change the value of some of your project compiler constants, you have to:

  1. click mouse on Project->Properties, or better press ctrl+P
  2. click mouse on the last tab Compiler options
  3. click again on the small plus next to Compiler constants
  4. click on the chosen CONFIG, backspace a few times, write the new value
  5. because enter doesn’t close the dialog, grab the mouse again and click OK

Now if you forgot to change also some other constant, you have to do the same again. And it’s pretty much the same if you want to check what’s the value of one of those constants.

FlashDevelop compilation constants

Seems like a lot of time? It is, especially if you’ve based the configuration of your project on those CONFIGs, you’re using them all day long, testing different builds. And in my case (probably not only in mine) that’s what’s happening – because they’re incredibly useful, allow to quickly change the build of the app in a fundamental way, in an mutually independent way.

… (read about the solution)