jsFiddle α
Share link
Share full screen result
Embed on your page (embed options)
http://mootools.net/blog/2012/08/01/javascript-challenge-2/ One of the most common requirements of web applications is to be able to respond to user input, and in particular clicks (or touches). Continuing with our theme of element generation (and in some cases animation); this week’s challenge will be to create a basic whac-a-mole game. The point of the game will be to click on highlighted elements to increase score. This can be as basic or as intricate as you wish it to be, but it should resemble the following diagram… The green block represents the block a player must click in order to gain points. This means you will need logic to randomly select one of the possible blocks and highlight it. You also need to register user clicks and update the score “label”. Hint: at times when you need to add many of the same kind of event to a variable amount of elements (in this case blocks); it is helpful and even efficient to use event delegation. You will need to use the setInterval() function or the setTimeout() function to create a predictable amount of time between each click or highlight.
Normalized CSS
Body tag
DTD XHTML 1.0 Strict XHTML 1.0 Transitional HTML 5 HTML 4.01 Strict HTML 4.01 Transitional HTML 4.01 Frameset
Framework <script> attribute
Echo apis are created to simulate Ajax calls: /echo/json/ for JSON, http://jsfiddle.net/echo/jsonp/ for JSONP, /echo/html/ for HTML and /echo/xml/ for XML.
/echo/json/
http://jsfiddle.net/echo/jsonp/
/echo/html/
/echo/xml/
Please read API documentation and follow examples.
jquery tweets, Delay, ElementStacks
twitter with dijits
Request.JSONP, Enhanced form, Request.HTML, Request.JSON, Delay, ElementStack
YUI+YQL Twitter example
Delayed Mouse Tracking
Delay
Created and maintained by Piotr and Oskar.
Hosted by DigitalOcean.
Special thanks to MooTools community.
License
All code belongs to the poster and no license is enforced.
JSFiddle or its authors are not responsible or liable for any loss or damage of any kind during the usage of provided code.
Links
Please read the documentation. For updates please follow our blog, tweets or become a fan.