Wednesday, June 29, 2011

The Unbearable Life of a Computer Programmer

Hello there Baller Industries enthusiasts. So lately I have been working on a game I have not talked about EVER on this blog. Why haven't I talked about it? I don't know.

The game is about an accountant, who is sent to meet with one his clients. On his journey to their offices something surprising happens and he becomes a little bit crazy. Instead of doing his normal accounting stuff he decides to fight everyone in his client's offices. How awful! I am going to name it Let's Get Fiscal.

LGF is going to be a side scrolling fighting game. Which means it requires a lot more programming than Get Rich or Die Gaming or Virtual Kelvin. What a bummer. This increase in programming leads to an increase in unbearable moments of horror. Let me describe one to you.


Meet Benny, he's a bad guy who appears on the first level of the game. The Treeboi and Kone club level. Benny has two attacks, a karate chop attack and a throw.

If you get within a certain distance of Benny he will attack you with his Karate chop, a skill he no doubt learned in Karate class. If you try to grab Benny, by sneaking up behind him. He will instead throw you to the ground. Perhaps to your death. So how do you defeat Benny you might ask? I don't know, figure it out yourself you jerk. I'm trying to tell you about the difficulty I had when programming today.

So the Karate chop works out alright, it was the throw I was having trouble with. If you get too close to Benny he will grab you. Sounds simple. Well it is not.





First I need to define a grab point for both characters. For Benny I need to define the X and Y position of where he will grab onto the Accountant. For the Accountant I need to define the point where he will be grabbed by Benny or some other guy who is grabbing him. To do that I open the sprite sheet up in Flash, draw a little mark where I think a grab point should go, and write down it's X and Y coordinate and then place that into my data files. Those coordinates are for the sprite sheet.

When a grab happens, Benny needs to align his baseline (where his feet are) to the baseline of the accountant. He also needs to allign his grab point to the accountants grab point. So to do that I:

1. Convert the grab points to world co-ordinates.
2. Measure the horizontal distance between the world-coordinates. This will measure the horizontal distance between the two characters grab points.
3. Then I add the horizontal distance measured in Step 2 to Benny's X position.


What I wanted



Unfortunately it did not work. Benny and the accountant seemed to have switched places. So I got angry and cursed everything. Then I discovered it was because Benny's being grabbed frame was not aligned with the idle frame. This meant it appeared Benny was jumping forward when he was in the grab state. No good. So I fixed up the bounding box and hoped for the best.




The best did not arrive. Instead I was faced with a new problem. I couldn't figure it out. So I went through lots of code that I was sure was fine. Code to convert from sprite-sheet co-ordinates to game space co-ordinates. Then I realised, it was because I did not change the grab point after fixing the bounding box problem. I fixed the bounding box problem by shifting the sprite to the left. So the x co-ordinate of the grab point should have also been shifted to the left. But it was not. So I fixed that up and met great success.

However I have once again been faced with great unhappiness. When making the pictures for this blog post I saved the accountant sprite sheet in MSPaint. This caused me to lose the alpha layer and this was the result.




CURSE YOU MS PAINT!

1 comment: