Over a million developers have joined DZone.

Introductory HTML5 + JavaScript game development: Duck Hunt

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

If you're looking for a clear, fun, and amusing introduction to game development with HTML5 and JavaScript, you might want to check out Matt Sorabian's Duck Hunt. The game is disturbingly enjoyable (complete with Matt's stream of dry canine consciousness), and the source is very clear.

Matt also includes some interesting notes on timing and callback problems:

"Another issue was ensuring that levels and waves were generated cleanly and only once. Because many things in this game depend on timers and animation callbacks there were (and likely still are) a few situations were the game could get a bit confused. One such situation was occuring if a duck was shot just as the wave timer was about to end. The chain of events would cause the (now defunct) nextWave() function to fire twice pushing you forward an extra wave, or level. Occassionally both would happen at once and things would be very hairy. "

Sometimes there's nothing more satisfying than running into subtle problems, solving them efficiently, and shooting ducks as a reward.

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}