Shark!
Well, this year's Shark Week is over. In its memory, I offer up a script that makes sharks swim around on the screen. You should see a few sharks swimming about right now! Here's the source code:
You can create new sharks like this:
The last example above shows setting a custom URL for the shark images. You can download those here:
There are a few different events you can subscribe to including onclick, onOutLeft and onOutRight, which I think are pretty self-explanatory.
Using these events, I put together a very simple game involving sharks, clicking and hopelessly trying to save a doomed diver. The ocean graphics came from one of my favorite CSS Zen Garden examples.
The shark script requires YUI (Animation, DOM and Event). I've included it in the third download option below:
- [Download shark.js] (3,747 bytes)
- [Download shark-min.js] (1,550 bytes; compressed)
- [Download shark-min-yui.js] (46k; compressed with YUI)
I'd love to see if anybody else has cool ideas of what to do with the shark script!


Wonderful.
Hm, apparently an update I made kills the shark animation. I have no idea why that’s happening. Any ideas?
Eek! Sharks!
Nice script btw :)