October 08, 2011
Click here to see a demo.
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
|Copyright 2011 © David Bau. All Rights Reserved.|