Flying Around

Spent some time making the ship turn to face the direction of thrust. This is a slightly tricky math problem that I had already solved back when this was a C++ project. The thing that always gets me is the trigonometry and the way that the resulting angles need to be wrapped so that they don’t get bigger than 180° or smaller than -180°. This was a chance for me to really make use of the browser’s debug console.

Whenever I would experiment with games in any engine, having powerful, clean debug output was always important. Sometimes, you have to write your own “console” kind of thing so that you can print data to it. The beautiful thing about building a game inside a browser is that any modern browser already has a fantastic debug console that’s lightyears beyond what I would write myself.

You can do the tried-and-true trick of just dumping data to the console from within your code, but even more powerful is the ability to just pause the game and start inspecting things. You can access any variable, as long as you’re in the right scope. You can set breakpoints and single-step through code, set watch values, change values dynamically, and just about anything else a full-featured IDE can do.

This saved me a lot of time debugging. Now, if only JavaScript wasn’t such a busted language. I guess you take the bad with the good.

Version here.

Latest version here.

Leave a Reply

Your email address will not be published.