October 08, 2011
Click here to see a demo.
jQuery-turtle source code here.
The extension adds the following methods to jQuery:
$(elt).turn(degrees) // turns elements right by a number of degrees $(elt).turnto(direction) // sets absolute compass direction $(elt).move(pixels) // moves elements forward by a number of pixels $(elt).moveto(location) // sets absolute position of the center of the elements $(elt).mirror(flip) // mirrors elements across the current axis $(elt).center() // returns the absolute center coordinates of an element $(elt).direction() // returns the absolute compass direction of an element $(elt).touches(target) // true if one element touches another $(elt).encloses(target) // true if one element geometrically encloses another $(elt).pen(color) // starts tracing a line with the given style $(elt).fill(color) // fills the elements with the given style
Any element can be turned and walked around the screen using turtle geometry and hit-tested against any other element. Key features of this extension avoid learning barriers for beginning programmers:
A Cat and Mouse Demo
Another example. Here is a simple cat-and-mouse game:
You press a key to go after the cheese, and let go of the key to flee back home. Source here. Try not to get eaten.
Posted by David at October 8, 2011 04:22 PM
I wish I could figure out how to use this. I tried to use this. My code $("#abc").play("abc"); is not making any sounds. What is the exact script I need to include on my page to make this happen?Posted by: Earl at December 6, 2013 05:11 PM
So upon further investigation the play function only works in google chrome. Is there any way to get it to work in other browsers?Posted by: Earl at December 31, 2013 06:08 PM
There were some bugs in jquery-turtle that have been fixed now, so play('abc') should also now work in Firefox 26.
(The issue was that jquery-turtle had been using a draft version of the WebAudio API - a few things have been renamed.)
IE still hasn't implemented WebAudio.Posted by: David at January 1, 2014 07:08 AM
pls can to make a cat to move in different direction like moving forward taking left turn, right turn and move ahead then again to backward.Posted by: gowthami at June 18, 2014 08:00 AM
Post a comment
|Copyright 2011 © David Bau. All Rights Reserved.|