Thursday, March 6, 2014

Gumball Fall - Stop & Squish The Bugs

Version 0.10.3 Released:


GumBall Fall v0.10.3: Web Player | AndroidGoogle Play BETA | Google+

There's that age old saying: Sometimes you have to stop and smell the roses. Well, what do you do if you find out those rose bushes are overrun with pesky insects?


Major Changes since v0.10.0:
  • Bug Fixes:
    • Fixed menu transition animation in Settings menu when users exit the menu via hitting the Android ‘Back’ button
    • Chains starting with Rainbow Balls will select proper color to pop when chains of 6+ are created
    • Score for selected chain now correctly displays above your finger/mouse
    • Suggested moves should work more reliably now
    • Board resets when no moves are present should work more reliably now
    • Gumballs should no longer fall when game board is clearing during Game Over
  • Ease-of-Use Enhancements:
    • Game Mode help screens can now be closed in 3 ways:
      • Tap anywhere on the screen (initially implemented way)
      • Press the newly created “close” button
      • Press the Android ‘Back’ button (i.e. escape key on keyboard). Users were constantly pressing this button and watching the game exit… which is what they didn’t want
    • Canceling moves is now more obvious: Drag your selection over the trash can button
  • Audio Updates:
    • Reworked volume settings UI in Setting menu to address audio bugs and to replace volume sliders with toggles
    • Reworked play music logic to ensure music is played at the correct times/locations
  • Graphical Updates:
    • Updated font used to render score from selected chain
    • Frank now informs you of the type of bonus you received (Rainbow, Bomb, Clear)
    • Most 3D models swapped for 2D sprites
    • Revamped gumball animation system allowing for more fluidly gumball animations
  • Various Performance improvements

Squash Those Pesky Bugs:


Over the last several weeks, implementation of featrues in Gumball Fall has been in a holding pattern. As much as I'd like to continue adding new (and, hopefully, fun!) features, sometimes you need to reflect and correct what you've done.

I've had a known set of bugs that I've continued to ignore for a while. I've dedicated the majority of my time this period to squashing them... or at least attempting to.

The majority of my (known) bugs do not cripple the core gameplay. They merely inconvenience and/or confuse the player:
  • Invalid suggested moves
  • Board reset when no moves present... Okay, this one CAN break core gameplay
  • Gumballs continue to spawn when the game is over
Without going into the nitty-gritty details, these bugs can be pretty much summed up by pointing the finger at less-than-ideal Coroutine design/usage. The logical underpinning behind each of features was solid. However, in an attempt to get these features quickly integrated, they were fired off in continuously running coroutines and left to fend for themselves. The longer a game round lasted, the more likely the coroutines' timings would drift from the actual game which increased the likelihood of these oddities showing up.

The reimplementation still uses coroutines but they now use a more event-driven one-time shot approach. For example, when the board is deemed to be in a 'stable' state, an event is fired off to make suggestions, etc. This eliminates any sort of looping time skew and ensures that the game will only perform these events at very controlled times. Thus far, the reimplementation appears to be working as intended.

Using Unity More Gooder!


‘More Gooder’ being a technical term, of course. I've mentioned in the past that, as a solo developer, I have neither the time or skill to recreate the wheel. If a suitable solution exists, I should consider using it to accomplish my goals. Well, as far as gumball animations for suggesting/selecting goes, I wasn't fully living up to my own words. Knowing full well that Unity provided a 'modernized' version of its animation system, I continued to stubbornly use their legacy system. Not embracing the new system amounted to me wasting time attempting to control many aspects of the gumball animations that I shouldn’t have had to concern myself with. Needless to say, using this legacy system forced me to introduce less-than-ideal logic into my game code that, ultimately, lead to various animation bugs.

Taking the handful of hours to migrate over to the 'modern' animation system immediately corrected these bugs. Additionally, transitions/blends between non-selected, suggested and selected gumballs look far more natural than they ever did using the old system.


All Hail Our 2D Overlords!


Gumball Fall plays out in a 2D universe, but, has historically used complete 3D models to represent said gumballs, bombs, etc. This release sees the removal of these models. They've been replaced with another new-ish feature of Unity: Sprites. The main rationale for the change came down to performance. When targeting mobile, every draw call counts. Ever extra vertex or polygon counts. I noted in a previous post that I had to make visual fidelity sacrifices in my 3D models to achieve some magic vertex count numbers to take advantage of draw call batching in Unity. While attempting to make the game more visually appealing (aka, adding more 'juciness'), the draw call numbers started to creep back up.

Sprites were the answer to my situation. The beauty of the sprite rendering system is that, with few (no?) exceptions, Unity handles sprite drawing as a single draw call. Shifting to sprites from 3D models instantly reduced my draw calls by a factor of 6. Additionally, the number of triangles getting drawn dropped from thousands upon thousands to around 800.

Overall, I'm happy with my move to sprites but, it did come with some drawbacks. Most notably, the automatic 3D shading I was getting with cube mapping my 3D gumballs is no more. My initial rendition of the new 2D gumballs were literally nothing more than solid colored circles. I could bake a shadow and specular highlight into the sprite, itself. But, if the sprite ever rotated, the shadow and highlight would rotate with the sprite... needless to say, not 'realistic.' While there are 3rd party shader options that claim to '3D shade' 2D sprites, I've come up with a 'hack' of a solution that, for now, is getting the job done. I've created a shadow/highlight sprite that simply gets independently superimposed over the solid colored circles. The circles can rotate all they want while the super-imposed shadow/highlight sprite's rotation remains forever constant. No extra draw call is needed for the shadow/highlight. Maybe not the most elegant solution, but, it works, looks decent, and has minimal performance hit on the game.

Before (left) and After (right)


It is worth noting that this solution probably will become annoying to maintain if I expand beyond just having simple gumballs. Creating/swapping/etc. the shadow/highlight entities for various shapes incorrectly could introduce some interesting visual bugs.

That’s all for this update. Give the latest build a spin and let me know what you think!

No comments:

Post a Comment