Palagpat Coding

Fun with JavaScript, game theory, and the occasional outbreak of seriousness

Friday, February 27, 2009

Cloning Zelda, part 4B: Now hear this!

A few weeks ago I discovered SoundManager2, a JavaScript library that uses a tiny, invisible Flash applet to enable audio playback directly via JavaScript! Awesome! But I had a heck of a time actually making the durn thing work with my data files.

First, I grabbed some WAV files for the original Legend of Zelda sound effects and music from a great LoZ resource site run by a good soul named HelpTheWretched ("Aren't online monikers fun?" says the guy who named himself after a Philippine bumblebee). I then used CDEX and its bundled LAME mp3 encoder to convert the WAV files to mp3 format. (this is a limitation of the current version of SoundManager: it can only play mp3s. No wav, no aac, no ogg. Bummer.) Finally tonight, after fiddling with SM2's troubleshooting page for a while and utilizing my mad copy/paste-fu skills, I got it to work! So if you go back to either of the Part 4 versions of the game (1x or 2x), you'll now hear the overworld music, as well as the slash of your sword!

As for the rest of the stuff that's actually supposed to be part of Part 4, namely the monster-killing stuff: I've fiddled with a couple of different options for collision testing, none of which I'm really very happy with yet. At first I thought maybe the getImageData() method on the Canvas 2d context object would be useful, and even roughed up a test to poll the sprite canvas for image data. But even though it would be pretty efficient at telling me about collisions in a particular coordinate location, I'd still have to back and figure out exactly what sprites those pixels represented. So I may just have to stick with a close approximation based on sprite sizes, positions, and velocities. I should have something worked out by next week.

Man, if "Part 3" had 2 parts, and Part 4 looks like it's going to have 3... sheesh, I think I'm going to have to rethink my original task list... =P

Labels: , ,


Post a Comment

Subscribe to Post Comments [Atom]

<< Home