JS Games-Blue Jigsaw Puzzles

Source: Internet
Author: User

First I am here to see this game (still in the editor ... )xPlease look here http://www.webhek.com/misc/inverter.

Begin The following is this little game, everybody play to see xClose oh! Blue Puzzle

Current level:

Reset This Council Reset Level Gameplay Instructions


Here is the code when I finish writing, I feel sick when I look at it. Want to put it in an object, but too lazy, can use on the line (つд⊂)
   . gamebox {        background-color: #4D4D4D;        border-radius:4px;        height:200px;        margin:0 Auto;        margin-bottom:50px;        position:relative;        width:60%;        max-width:500px;    }    . Gamecard {        Background-color:rgb, 171, 94);        border-radius:4px;        Position:absolute;    }
    var Gamebox;    $ (function () {        Gamebox = $ ("#gameBox");        Loadlevel (1);        $ (window). Resize (function () {            setboxposition ();        });    });    var gameoptions = {        level:1,        border:15,        array: []    };    function Showhowtoplay () {        bootbox.dialog ({            title: "Gameplay description",            message: "

How to win: make the puzzle blue.

How to play: each block is orange, one blue side. Clicking on a block will flip the color of the block, and the color of the block adjacent to it will also be flipped.

", buttons: {btn: {label:" Understanding ", ClassName:" Btn btn-succ    ESS "}}}); } function Reloadlevel () {Bootbox.dialog ({title: "Are you sure you want to do this?                    ", Message:" You're going to restart the game from Lv1, "buttons: {cancel: {label:" Forget It ",                    ClassName: "Btn btn-success"}, BTN: {label: "I'm sure",                     ClassName: "Btn Btn-danger", Callback:function () {loadlevel (1);    }                }            }        }); } function Reloadgame () {Bootbox.dialog ({title: "Are you sure you want to do this?                    ", Message:" You will restart this level of the game ", buttons: {cancel: {label:" Forget It ", ClassName: "Btn btn-success"}, BTN: {label: "I'm sure", ClassName:" Btn Btn-danger ", Callback:function () {Loadle                    Vel (gameoptions.level);    }                }            }        });        } function Fillcard () {gamebox.empty ();        Gameoptions.array = [];            for (var x = 0; x < gameoptions.level; + +) {var row = new Array (); for (var y = 0; y < gameoptions.level; y++) {var card = "
 
"; Gamebox.append (card);            add element Row.push (0); } gameOptions.array.push (row);        Add a two-dimensional array that defines the state of the element, by default all 0}} function setboxposition () {var boxwidth = Gamebox.width (); Gamebox.height (Boxwidth); wide and high equal var border = Gameoptions.border;        Interval width var len = (Boxwidth-(gameoptions.level + 1) * border)/gameoptions.level;                for (var x = 0; x < gameoptions.level; + +) {for (var y = 0; y < gameoptions.level; y++) {                var ele = Gamebox.children ("div[data-x=" + x + "][data-y=" + y + "]");                var Elex = x * len + (x + 1) * border;                var Eley = y * len + (y + 1) * border;                Ele.css ({"Left": Elex + "px", "top": Eley + "px"});            Ele.width (len). Height (len);        }}} function Loadlevel (level) {gameoptions.level = level;        Fillcard ();        Setboxposition ();  $ ("#tip-level"). html (level);  } function Clickcard (x, y) {changestate (x, y);        Changestate (x-1, y);        Changestate (x + 1, y);        Changestate (x, y + 1);        Changestate (x, y-1);    Checkwin ();        } function Changestate (x, y) {var lel = Gameoptions.level;        if (x < 0 | | x >= LEL | | y < 0 | | y > Lel) {return;        } var num = Getnum (x, y); num = num = = 1?        0:1; Setnum (x, y, num);        The current block state changes var ele = Gamebox.children ("div[data-x=" + x + "][data-y=" + y + "]"); Ele.css ("Background-color", num = = 1?) "RGB (144, 255)": "RGB (230, 171, 94)");    Change color} function Setnum (x, y, num) {gameoptions.array[x][y] = num;    } function Getnum (x, y) {return gameoptions.array[x][y];        } function Checkwin () {var win = true;                for (var x = 0; x < gameoptions.level; + +) {for (var y = 0; y < gameoptions.level; y++) {          var num = getnum (x, y);      if (num! = 1) {win = false;                Break        }} if (!win) break;            } if (Win) {var Lev = gameoptions.level + 1; Makedialog ("Complete jigsaw puzzles!            "," go to the next level, Lv "+ Lev, function () {loadlevel (Lev);        }, 10); }    }

.

JS Games-Blue Jigsaw Puzzles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.