The js code :
#js var tetris = new uTetris($('container'), $('preview'),{ keypress: true }); var play = $("play"), score = $("score"), level = $("level"), lines = $("lines"); tetris.addEvents({ "start": function(e){ setInfo(e); setPause(); }, "lines": setInfo, "fixed": setInfo, "pause": setPause, "gameover": function(){ play.set("html", "Play"); } }); function setLabel(str) { play.set("html", str); } function setInfo(obj) { level.set("html", "Level: " + obj.level || 0); score.set("html", "Score: " + obj.score || 0); lines.set("html", "Lines: " + obj.lines || 0); } function setPause(pause) { setLabel(pause ? "Resume" : "Pause"); } play.addEvent("click",function() { if (this.isStop()) { this.restart(); } else { this.pause(); } }.bind(tetris));
The html code :
#html <div id="main"> <div id="left"> <table id="container"></table> </div> <div id="right"> <div id="info"> <div id="score">Score: 0</div> <div id="level">Level: 0</div> <div id="lines">Lines: 0</div> </div> <div> <table id="preview"></table> </div> <div id="controls"> <a href="javascript:;" id="play">Start</a> </div> </div> </div>
Public Methods :
Events :
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus