Today, I used OO to write a keyboard and letters game, which can be used for normal keyboard exercises. What's wrong? Thank you for pointing out. Mainly achieved results: 1. the accumulation of points is realized; 2. points... syntaxHighlighter. all (); News & nbsp; today I used OO to write a keyboard-letter game, which can be used for normal keyboard exercises. If it is hard to write, thank you for pointing out. Mainly achieved results: 1. Accumulated points; 2. Upgraded points to a certain extent; 3. Game failure when letters fall to a certain extent. The following code is provided:
Keyboard game full version Script var speet = 1; // The moving speed function createDiv () {var createbutton = document. createElement ("div"); createbutton. style. width = "800px"; createbutton. style. height = "1000px"; createbutton. style. border = "2px solid"; document. body. appendChild (createbutton);} function createSource () {var createSource; var score = 500; // The lowest point for the upgrade var sco = 0; // The Point var I = 1; // level init (); function init () {createSource = document. createElement ("div"); createSource. style. width = "100px"; createSource. style. height = "20px"; createSource. style. border = "1px solid blue"; createSource. innerHTML = "points:" + sco; createSource. position = "absolute"; document. body. appendChild (createSource);} this. leijia = function () {sco + = 10; createSource. innerHTML = "points:"; createSource. innerHTML = "points:" + sco; // alert (zhengbai); if (sco = score) {score + = 500; alert ("Congratulations to the upgrade: "+ I ++); speet + = 1; alert (" speert ----------------- "+ speet) ;}} function CharA (charDiv) {var CharArray = new Array ("A", "B", "C", "D", "E", "F", "G", "H ", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R ", "S", "T", "U", "V", "W", "S", "Y", "Z"); var a; init (); function init () {a = document. createElement ("div"); var charDiv = CharArray [parseInt (Math. random () * 26)];. innerHTML = charDiv;. style. width = "50px";. style. position = "absolute";. style. height = "50px";. style. top = "50px";. style. left = Math. random () * 100 + Math. random () * 500 + 50 + "px"; document. body. appendChild (a);} this. shoaa = function () {init ();} this. move = function () {. style. top = parseInt (. style. top) + speet + "px"; if (parseInt (. style. top)> 700) {alert ("game over"); clearInterval (time) ;}} this. charinner = function () {return. innerHTML;} this. hidden = function () {. style. display = "none"; document. body. removeChild (a) ;}} function Game () {var chars = new Array (); var cs = new createSource (); createDiv (); function initData () {for (var I = 0; I <10; I ++) {var charA = new CharA (); chars. push (charA) ;}} initData (); this. start = function () {time = setInterval (function () {for (var I = 0; I