Wednesday, August 24, 2011

T minus 17 days- complete failure on short-term deadlines

But it's ok, I got lots of work done.

Because I didn't have the "uses-sdk" and "supports-screens" tags in my AndroidManifest.xml, the screen wasn't scaling correctly-- meaning opengl was drawing to a surface half the size of my phone's actual screen and then scaling it afterwards. With this fixed, the game now correctly renders to the entire screen... which caused a 10 frames per second performance hit. The game was now running at 35 frames per second.

So, instead of making my bear run around and attack the player, I frantically optimized.

Easy optimization:
  • Get rid of getters and setters. Changing entity.getX() to entity.x improved performance by a solid 5 fps.
  • Use local variables whenever possible especially in "for (... i < array.size() ...)".
Hidden, annoying optimizations:
  • Apparently, the game was making a single Integer object every time a sound was played. That single object caused garbage collection every 30 seconds, making the game stutter.
Big optimizations:
  • (Intentionally) rendering to a smaller resolution, then scaling up the result. This led to unreasonably *huge* gains. I'm surprised I haven't seen this in other games as the jump in performance is enormous.
with 75% resolution (~55 fps)

full resolution (~35 fps)

  • Allow the user to disable parallax layers (-5fps)
  • Don't load new textures, change texture crop, etc if you're still working with the same texture. This is obvious, but saves a lot of time, especially when rendering bumped platforms (because those are a series of the same sprite, over and over)
Working with re-sizing the resolution manually forced me to actually fix how the game renders on different sized screens. I haven't tested it on a tablet, but I'm fairly certain it now renders sanely on all devices, and that regardless of DPI, the game should appear to be similarly scaled.

Anyway, changelog:
  • Added more gfx options.
  • Screen resolution scaling.
  • Fixed looping world bugs.
  • Lots of optimization/testing.
  • New proto-sprites
Here are those sprites! I've worked on a ghost, a bear and a yeti.

Also, sadly no youtube today. But, in it's place:


No comments:

Post a Comment