Thursday, May 23, 2013

The Late Postmortem of Nine Lives


Here it is folks, My Nine Lives sprint to prototype postmortem analysis.

I'd like to divide this assessment into three major sections, time management, art, code. I would have included a fourth 'design' category but this is a game that I had previously designed and so during this week I didn't do any design work. Check further down for my TL;DR section.

Time Management
When I first thought of doing this I had planned to give myself 48 hours and keep the schedule of a game jammer. Two of my three game jam experiences went over extremely well and I liked putting a game together before I could get bored with it. However, when I first sat down to write this dev blog I decided that I should instead give myself a week. I was, after all trying to achieve a few things I had never even attempted before and I would be doing both the asset creation and game implementation. Plus, I would have to have time to cook meals, shower, work out, and generally live life. I couldn't abandon all of my other responsibilities in order to indulge myself.
I started Tuesday night. I was confident at the outset that I could tackle the pixel art goal I had given myself. Designing a character and sketching it are my specialties and so that took all of 5 minutes to iterate through a few designs, settle on one I liked, sketch a walk cycle, and scan it in. I looked up a pixel art tutorial and got to work. I spent twice the amount of time I wanted to spend on pixeling and animating my avatar. I laid my first pixels the morning of the 15th and finished the night of the 16th. Two full days spent on a character animation the didn't even make it into the final prototype.
From a purely, 'did I reach my goal?' stand point making the pixel cat and animating it's walk cycle was a complete waste of time. However, from a, 'did I learn pixel art?' stand point it was a huge success. I can now definitively say that I understand more about pixel art and how to implement it than I ever have before. More of this will be covered in my art section later.
The 16th was a Thursday and the last day I worked on creating the art for Nine Lives. I spent most of Friday backing up files, renaming files, flipping my sprites so my avatar can walk left, and reading about Game Maker. I even completed a few tutorials but they were all drag and drop tutorials and left me feeling like I didn't really know what was going on. I hardly worked on anything again until Sunday when I sat down and really dug into the code.
I hadn't coded for a few weeks and certainly not in an environment like Game Maker so by the time Sunday was over I felt as if I really didn't have any chance of completing this game. I posted about how it was a learning experience and that I may have bit off more than I can chew. I was mad that I had to post that and so the next day, with two days left, I went for it. On Monday I was able to get my cat walking correctly and have it's other 8 lives follow it. Then, I got it jumping, kinda. I had a made a few mistakes in my movement code and I was getting stuck in the floor. Tuesday rolled around and I was able to work out the bugs. For all intents and purposes I emerged victorious.
Overall, I believe my time could have been managed much better. For one, when building a prototype, get the game play done first. The art wasn't as important to the game at this stage as the programming and design were. I'm happy that my prototype works and that my avatar is a pretty cool cat but I would rather have it working with no avatar than an avatar with a broken prototype. Also, learning new things takes time. I know that sounds obvious but what I actually mean is that in this project I not only tried to learn two new things but I tried to execute them as well. I went in cold and could have ended up coming out cold. Luckily for me that wasn't the case. However, if I had learned the tools before hand and then tried to prototype this game I think I could have done it much faster.

Artwork
I've always had an aversion to doing pixel art. It's time consuming and required that I not only be good at drawing, color theory, and be familiar with how certain digital image files work but it specifically required me to be good at working with pixels. This may seem incredibly obvious but pixels are an incredibly restrictive media. I believe that under tight restrictions true creativity can grow but damn is it hard.
I've practiced and worked most with traditional media. I have sketchbook after sketchbook filled and resting on the shelves around my desk. Last year I took a color theory class and expanded my work out of graphite, charcoal, and ink into colored media such as colored pencils, water soluble crayons, oil pastels, water colors, and digital media. Even after years and years of practicing and honing my art skills I was still feeling timid to try a new media. Going from an intermediate level to the very beginning level at something is daunting.
Wednesday morning I put down my first pixels. I made the canvas 256x256. It's a generous size when doing pixel art but the more room you have to work the easier it is to draw something and I thought I'd apply the same aspect to my cat avatar. I scanned my sketch in and sized it so that I could put it on a lower layer and use it as a guide. If you check my earlier posts I link to the tutorial I followed. By the end of the day I had created my avatar with some arms and legs.
The entirety of the next day was making the eight frames needed for a walking animation. By the end of the second day it was no longer difficult to get the shapes I wanted. I understood how to create curves a lot better and it was becoming more natural. However, when I went to put my avatar into the game I noticed something horrible. My avatar didn't take up the entire canvas. It's was actually 121x208. I didn't have time to fix it as I was a day behind my original deadline to start coding.
I think the next time I do pixel art it'll be much easier. Since I plan to take this game idea further out for a couple of weeks I'm sure I'll have plenty of practice. I'll have to remake my avatar in an acceptable and probably smaller size. Pixel art is tedious but it's extremely rewarding.

Programming
This isn't the first game that I've coded. I recently completed all of the coursework necessary to graduate with an associate of science in game development. The degree program is mostly a computer science degree with a bunch of multimedia sprinkled in. I have experience in Java, C++, C# in XNA Studio, Action Script 3.0, and Unity's Javascript. I've never attempted to learn a language on my own. I've dug deeper into a language than my coursework would have lead me but that's it. I know GML isn't supposed to be a difficult language and for the most part it wasn't.
The first hurdle I had to overcome was how variables and objects were made. Variables can be assigned value without any conventional declaration. There's no variable keyword needed. You can simply type, “cats = 9,” and a variable called cats will be created that stores the integer 9. At first I wanted my cats to have certain member variables and in any other language I would include that in the cat object. However, in Game Maker I had to include that in the creation event so that when it was instantiated all the variable were created at certain values.
The second hurdle was movement. From C# I'm used to the top left corner being the origin. In Game Maker I'm not entirely sure. When checking if a spot 6 pixels to the right is free you don't have to add the sprite’s width to the x coordinate and then add 6 you just add 6 to x. I don't know why but that's how it's done. Same with the y coordinate. That tripped me up more than I'd like to admit. It caused me so many problems with getting stuck in the floor, thinking my place_free(x,y) function was returning the opposite values it was supposed to, and just generally causing mayhem. Thankfully, I spotted the problem fairly quickly.
The third hurdle was a data structure hurdle. A class I'm sad to say I didn't do very well in. My cats were governed by an invisible cat manager object. I wanted the manager to dictate how they interacted with each other while the cats controlled themselves individually. This ended up giving me a lot of head aches. At the start of the room the cat manager would instantiate a number of cats equal to the number of lives the player had and designate one as the active cat. I put all of the cats into an array and then gave them a member variable called index that reflected there spot in line. The active cat would be index 0 and the last cat would be index 9. I did this because originally I wanted each ghost cat to follow the one in front of it. They could ask the manager for the cat in front of them by there index. However, that created a huge mess.
The index didn't correspond to there index in the array. So when each cat was asking for the index in front of them they were actually asking for that spot in the array which wouldn't necessarily be the next cat in line. So then I tried doing it a different way. When I switched cats I wouldn't assign a new value to a member variable but would rather temporarily store the cat elsewhere and then shift all the cats forward eventually ending up with the first cat put in the last position. As I was implementing this I realized what I was actually creating was a queue. I quickly googled to see if there was a built in queue and luckily for me Game Maker had one.
My code instantly became easier to read and all around more elegant. I simply de-queued the head and the en-queued it. The biggest problem now was the code to get the cats to follow the cat in front of them. Queues don't have indices. I couldn't access each cat in the queue unless it was at the head or the tail. Fortunately for me it came to me at the gym. I just had to give each cat a member variable of index again. Then, when I de-queue it I add the number of lives to it and then en-queue it. Basically, if I de-queue the first cat (index 0) and then en-queue it and add 9 (the number of starting lives) it's index becomes 10. Now, instead of having indices of 0-8 I have 1-9. This way each cat could ask itself how far it's index is from the head and follow from a certain distance. Using this formula the relative distance would never change. Even if I lost a life and ended up with 2-9 (8 lives). When I switch again I'll have to add 8 (the number of current lives) to 2 and end up with 3-10. Their indices would climb and climb and climb but I could always check and make sure they never went too high and if they did I could simultaneously set them back down.
My last piece of coding was the inventory. This was exceptionally easy thanks to Game Maker. I just had to specify what would happen if the active cat collided with my powerup object. One of the events that is collision and then you choose the object. It's fantastic. When the cat collided I executed a code. Basically, destroy the object, set the powerup variable to “powerup” or literally any other variable. Done. Now that cat has a powerup in it's inventory. When I press certain keys I just need to test what that powerup variable reads and boom, I've got special powers.
I'd have to say that Game Maker, although limiting, does make things super easy. I learned the language and prototyped a game in a week. It has it's quirks but I think it's worth working in. I'd say it's a great tool for anyone that wants to make games rapidly.

TL;DR
  • I should've spent less time on art
  • Postmortems take a long time to write
  • Learning new skills as you go is time consuming
  • Pixel art is tedious, limiting, and rewarding
  • GML variables are weird
  • Data structures are important
  • Where's the origin of my object?
  • I'm continuing development for a few more weeks to see where it takes me

No comments:

Post a Comment