Game Development Reference
In-Depth Information
All of these Web-based optimizations directly translate into performance improvements on
the Windows 8 side of things as well. The reduction in file size makes it easier for users to
download your game and store it on their computer, and it lowers the overall memory foot-
print as well. This last point is especially critical on lower-powered Windows 8 devices that
may only have 32 or 64 gigs of storage and only two gigs of memory.
There are a lot of great texture packagers out there and some are free, such as ShoeBox ,
while others cost money but are more robust, such as TexturePacker .
Optimizing Code
It's next to impossible to cover all of the ways you can optimize the JavaScript in the scope
of this topic, but I have a handy list of “code smells,” which is a developer term for code that
could contain deep problems you should look out for before publishing:
▪ Always use multiplication instead of division and avoid other complex math equations,
such as square roots, unless it is absolutely needed.
▪ Avoid complex, deeply nested loops. If you have multiple nested loops, try to simplify
them and see if you can get away with a single loop. Loops are code blockers, meaning
nothing can execute until they complete, so try to limit or avoid them where possible.
▪ Use RequestAnimationFrame instead of SetInterval for your game loop. I had a dramatic
speed increase in my own games by making this switch, and it should help anyone mak-
ing a Windows 8 game or even a Web version of their game on modern browsers.
For the difficult-to-track-down performance issues, I suggest taking advantage of Visual Stu-
dio's Performance Explorer, which you can find under the Analyze -> Window menu. Fig-
ure 5-18 shows when I run my own game.
Search WWH ::




Custom Search