Last week ended on a bum note, with a game that did not seem to be any fun, begging the question, "Why continue?" I continued anyway, and I'm glad I did. Unfortunately, though, this week ends on a bum note as well. I wanted to transition from the simple territory system I had in place to what would actually be the system in the final game. I knew implementing this would require some creativity on my part and I really wanted to see if my theories on what to do would actually work. See, there were two challenges. One was drawing the territory on the game screen how I wanted it to look, and the other was to generate silos only in a player's territory. The first job sounds easy until one thinks of it in context of the second. Chances were that I would have to use collision code to make sure that silos ended up in the correct territory, basing it off the rejection method that ensures silos end up in a circle, like I did before. The easiest way to make this work would be to use the player and AI controller objects and make it possible to collide with them. Their sprites would be the territory of their respective countries. Thus drawing them on screen would require that either country's sprite always ends up in the same place regardless of which player it is associated with, and, more challenging, that their borders always line up. 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. I was proud of the result and it did feel like somehow it had made the game feel more fun. In the process of working on this feature, though, I came up with a solution to the problem of the game ending far too quickly. Instead of having the confession of a spy end the game, it results in the enemy basically taking another turn, with the possibility of launching a preemptive strike. Thus a confession is always bad, though not necessarily devastating. I implemented this change and felt like the game had improved considerably. I felt like I was still having to make decisions in order to win the game, and that I could still lose, but winning was now possible (I did win a few games myself). 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.
1 Comment
|
AuthorCurtis Miller is an instructor and graduate statistics students at the University of Utah. Archives
June 2016
Categories
All
|