Thursday, October 6, 2011

Clean Up and Pest Control

**Check out the Update so far at my portfolio:

michaelpiercy.ie

The last couple of days has seen a spring clean up of code. Some bugs that were causing unforeseen problems have been sorted as well as sound effects and animations added (more to be added soon).

Clean Up
Organising the functions a little neater is a good way to remind you what's doing what in the game. sometimes you may have forgotten that you added a variable or function here and there but didn't need to use it in the end. Cleaning up the code halved the amount of lines in the game which is a great way to cut down on file size and keep the Frame Rate up.

Bugs
Filtering through the code line by line is a very daunting task but sometimes it's the only way to solve that problem buried within the hundreds of lines of code. With that said, I've learned over the last couple of days that sometimes taking a few minutes break, grab a drink, a bite to eat; Let it all fall out of your head and more often than not, the solution presents itself.

Animations and Sounds Effects.
I had a bit of a problem getting the animations all working nicely. Each Quart was programmed to play the 'Pop' animation just before it gets deleted. After it's deleted another lot of code was constantly checking to see if there's any Quarts missing - if there were it would replenish them and the new quarts would fall from the top of the screen.
Sounds like a nice plan, but in practice something was going wrong. Sometimes the new Quarts being added were not lining up correctly. I'm a big believer in 'The Computer will only do what it's told' philosophy, so it was quite frustrating when I carefully scanned every line of code, arranged and re-arranged the calls and functions to no avail. I spent a long time testing and re-testing trying to find a solution until eventually I took a break. In my head I went over what was happening but away from the computer. Suddenly it hit me.
The Code was working fine, everything was doing what it was supposed to be doing. The Quarts were deleting when they were supposed to and the correct amount of new ones were being replenished. But the two blocks of code were not working linearly, it was happening almost simultaneously.
The code that checked to see if there was any quarts missing was in the middle of counting when the matching quarts were in the middle of finishing their animations before being deleted. So the count result was sometimes incorrect. A simple check to make sure that all of the animations were finished before re-counting fixed the bug.

I've also been working on some layout designs:


This was before the decision to change the game-play slightly. Now the screen is always full and with a 5x5 grid rather than this much larger grid, but it still gives a good idea of the planned layout.

No comments:

Post a Comment