
A romantic evening on the landing pad
April 29, 2008Yes, Biff and I just spent a very romantic evening together. And by “romantic” I mean, of course, full of infuriating debugging.
There are landing pads now. Well, there’s one. So you can fly up to it, slow down, and land your plane to get back to the plane selection/arming screen. Relaunch!
The nasty debugging came in when I noticed that after relaunching, your plane is much faster. Faster acceleration, faster turning rate, etc. This is bad. I was led on a wild goose chase thinking that somehow the plane entity was having its turning rate and whatnot added onto itself, hence getting faster with each relaunch.
Of course, incredibly incorrect. I stared blankly at the wrong code for a while. Sort of watched a movie (The Man From Earth: definitely not recommended) while I did the staring. Run more tests. No luck.
Once the [hokey] movie was over, I had a sudden realization. The launching caused the player entity to be respawned, meaning there are two references to it in the sprite manager (or three, or four, etc depending on how many times I landed and relaunched). Only one instance, but two references. So the sprite got updated twice every frame rather than just once, thus doubling the acceleration, etc. Always obvious in hindsight.
Anyway. I set up the entities so each instance can only be spawned once. This might come back to bite me later.