Wednesday, November 7, 2012

Fallen: Artwork, Upgrade menu, and linked lists

Its been awhile since I last posted, but I've been really busy with school work and midterms. I haven't been able to focus as much as I wanted on Fallen for that reason and the fact that I have to wait for the artist to finish some assets. The artwork is going great and Cory Stivers is an awesome artist who can get some quality work done in a quick amount of time.


This is the concept for the angel.


These are the sprites of the angel for mercy. 
(Left: The attacking animation, Center: This is for walking, but the animation doesn't seem to be working, Right: the idle animation)



These three are the backgrounds for the first level. These don't include the Statue which acts as the platforms. 

Now that some good stuff is out of the way. What I did this past week and a half when I did have the time was create the Upgrade menu, pause ability, and a upper HUD to show which ability the player can use and what key it is mapped to. The upgrade menu was the hardest of it not because it was a challenge, but because game maker and GML is not like any normal programming language. 

The way the upgrade menu works is that there are three trees of abilities (Justice, Vengeance, and Mercy). Each point you get by leveling up, you can spend on an ability. You can purchase any ability on the tree, but you must have purchases the previous ability. So in order to get Justice level 2 ability, you must purchase the Justice level 1 ability. This should be easy to do, but the first thing that bugged me was laying out each button. Normally what I would do is utilize object-oriented programming by creating a master button that each subsequent button extends off of. Game Maker kind of does that, but it really is weird and doesn't act like a true super class, especially when it comes to overrides. What I decided to do is to create one button and to have parameters specify where it will be and what ability it would activate. Again this should be easy, but GML doesn't have a new Button() call. Instead what it does require when you want to create a new object is to call instance_create(x, y, obj). Parameters can't be used to customize it. What I had to do is the following code.

button = instance_create(x, y, obj);

with(button)
{
    //initialize button here
}

In GML, with acts like a for each loop. If you put in an object name, then it will loop through each object on the stage. If you put in an instance id, then it will just do the instance. This is very annoying because and code inside the with loop is called as if its inside the actual button. So a call of instance_destroy() inside the with loop is like button.instance_destroy(). However, you can't call button.instance_destroy() or any other methods to apply to an object. The only thing you can call from an object is a global variable. 

I was able to lay down the buttons and set them so that any ability that could be activated could be selected. Now came the second part. If the player decided to accumulate more than one point, then they could purchase multiple abilities down a tree. This required me to set up a system that would check to see if the previous button was selected so that if it was selected, then the current button could be selectable. This caused the problems. Each button has no knowledge of any other button, so I had to create a data structure that would host each button in sequential order so that the previous entry was the previous button. The obvious choice for me was a linked list. GML has no linked list. What it does have is a list that is similar to the ArrayList in java or a list in C# or a dynamic array (vector). So I create this list hoping that it would function the same as a linked list. To my surprise not only does GML list have no iterator. But when I did find a way to get the previous entry, the code to check to see if the previous was selected didn't work. No matter what I tried, I couldn't get the code the let the next selectable button to be selectable. 

Normally I would debug by stepping through the code, but GML doesn't have a step in functionality in its debugger and prints didn't tell me anything useful. I couldn't think of anything else to do, and I had to continue on the game and get it ready for the Alpha, so I dumped the functionality and just had to have the user select one upgrade at a time. I really hate game maker. Its reasons like this that I wished I had used actionscript 3.0 and flash to create the game. But I'm stuck with my decision and will have to trudge through the finish. 

No comments:

Post a Comment