Before accomplishing this, though, I had to actually have sprites to work with. In my design process, I had drawn out the fictitious borders of East and West Cormania along with the coastline. I have a handheld scanner, and I used it to scan the image. Then I used Inkscape to trace out the vector for the map that I wanted. The latter part was tricky since I hardly consider myself a pro with vector graphics. But after lots of trial and error and learning, I did manage to get good borders, which I then took into GIMP to create the .png images that would actually be used in the game, including the images for masks necessary for the collision code.
The solution to ensuring that the borders always lined up was very simple. I made the images containing the borders and masks all the same dimensions, large enough to hold the entire image. The position of the countries does not change in these images relative to the positions of every other country. This means that as long as all the sprites had the same anchor point (I chose the center), all borders would be in the same place relative to each other and thus would always line up. The same was true for the territory masks.
In the end, making the game create borders and ensure that silos would always end up in a player’s territory wasn’t hard. Each territory had an invisible mask for that territory associated with it that would be used for collisions. I used the rejection method detailed in an earlier post, randomly generating a point in the bounding box of the collision mask until that point collided with the mask (which had precise collision checking, which MUST be one for the method to work). After this the game is basically the same.
This was the high point of the week. After that things went downhill. See, requiring that the player use all his resources means that the player could have an arbitrarily large number of spies, and there simply isn’t enough room on the screen for all of them. Usually the game wraps up before room runs out, but I did not want players to end up hosed because a spy was inaccessible due to being off the screen. I had no choice but to add a system for handling overflow.
The solution itself is easy to understand. If the number of spies exceeds some critical value, then only spies within a certain range of numbers is drawn in the espionage section of the UI; the rest are drawn offscreen. The user could modify this range and always be able to access all his spies. All that needed to be added was a way for the player to cycle through his spies, which would be activated when the critical number of spies is reached but deactivated otherwise.
I tried recycling the addition/subtraction buttons that I had been using to modify production numbers. This did do the job of cycling through the list of spies, but somehow created extremely strange behaviour in the nation controllers. Whenever a turn ends and those buttons are on, the x position of the nation controllers is changed and taken almost offscreen. This is the nastiest bug I have encountered to date, buried somewhere in the code. Sadly, the debugger has not enlightened me on why this is happening. It appears that there is a conflict with the command line that I added for testing purposes, as the problem seems to go away when that object is removed. But why there is a problem is not at all clear. I cannot even find where these objects are associated with each other!
So how do you fix a bug when not even a debugger as good as GM:S’s will tell you where the problem lies? I think that I may need to do some restructuring that I did not originally want to do and pray that it works. I hope that this is fixed by tomorrow. Right now, I am transitioning from the phase of the process where all I want is a prototype to what I am calling the “beautification” phase, where all sorts of glitz and glamour not necessary to base play (though not necessarily purely aesthetic) is added to make the game more playable and more aesthetically pleasing. I have ambitious plans for this phase that will most likely involve shaders and surfaces, which represent new territory for me. I don’t want a very silly bug to hold me back from this.