scriptNode

Web development with a focus on JavaScript RSS

Shark!

Advanced Matt Hackett Published August 3rd, 2008 by Matt Hackett

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:

Shark! Shark!

Shark! 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:

I'd love to see if anybody else has cool ideas of what to do with the shark script!

Read other articles tagged: , , , , ,

Comments (3)

Thoughts?

(required)

© 2008 scriptNode