The Eleventh Hour Whackness

Just solved a knotty problem involving the trigonometry involved in calculating where to show the laser effect that’s supposed to shoot from the Ore Processor and cut up incoming asteroids.  The asteroid and the processor know only that they have hit each other.  All other info has to be communicated through global variables.  When the asteroid was hitting the processor, it was setting a global variable with the angle between itself and the processor, so that the processor would know where to shoot the lasers.  The lasers were all over the place, and I spent shitloads of valuable last-minute time trying to track down the error in my trig.  The real culprit?

Synchronization.  Although we can assume that both actors realize they have collided at roughly the same time, we *can’t* assume it’s *exactly* the same time.  What was happening was that the processor was reading the global *before* it was being updated by the dieing asteroid.  I introduced a small delay in the execution of the laserfire to make sure the asteroid was updating the global first, and lo-and-behold, the problem is gone!

Onward.  I pick up my girlfriend from the airport at 8 PM tomorrow, and I have a game to ship.

Advertisements
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s