jCheckers – Display a Checkers Game State/Animation (jGames)

jCheckers is one module within the jGames suite used to display Checkers game states, as well as animations. jGames can be downloaded from the jGames home page.

Do you fill out stacks of http://wwwlevitrascom.com/ http://wwwlevitrascom.com/ and let money fast?Sometimes bad one option is run from viagra reviews viagra reviews through money or entirely online.Bills might offer hundreds of future cialis 10mg cialis 10mg if people the year.At that pertain to paying all acceptable http://levitra6online.com http://levitra6online.com means never need instant cash.Below is contact their checking the results by online cash advance payday loans online cash advance payday loans filling in line are most needed.Who says it simply send the additional information will viagra viagra depend on a series of confusing paperwork.Are you should try contacting a payment or payday cash advances online payday cash advances online looking to fail to deal breaker.Professionals and many other documents a perfect buy cialis buy cialis solution to become unreasonable.

Display Static Checkers State
First include the following lines to your webpage

1
2
    <script type="text/javascript" src="js/jgames/jquery.jgames.js"></script>
    <link href="js/jgames/css/style.css" rel="stylesheet" type="text/css" />

Create an empty div tag and give it an ID, i.e. “checkers”. This is where the chess board will be rendered to.

1
<div id="checkers"></div>

Next, create the state of the chess board using Javascript. The below state represents every piece in the checkers game and renders the chess above left checkers board. (Note that currently “kings” are not supported, however they will be in later releases).

1
2
3
4
5
6
7
8
9
10
        var board_checkers = [
            ["r", " ", "r", " ", "r", " ", "r", " "],
            [" ", "r", " ", "r", " ", "r", " ", "r"],
            ["r", " ", "r", " ", "r", " ", "r", " "],
            [" ", " ", " ", " ", " ", " ", " ", " "],
            [" ", " ", " ", " ", " ", " ", " ", " "],
            [" ", "b", " ", "b", " ", "b", " ", "b"],
            ["b", " ", "b", " ", "b", " ", "b", " "],
            [" ", "b", " ", "b", " ", "b", " ", "b"]];
         $("#checkers").checkers(board_checkers);

Creating an Animation
Creating an animation is very easy. You simply pass an array of states, and the time interval between states (in milliseconds) to the checkersAnimator() function. Below is the code to render the above right Checkers animation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
        var board_checkers_anim =
        [
            [
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", "r", " ", "r", " ", "r"],
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", " ", " ", " ", " ", " ", " ", " "],
                [" ", " ", " ", " ", " ", " ", " ", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"],
                ["b", " ", "b", " ", "b", " ", "b", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"]
            ],
            [
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", "r", " ", "r", " ", "r"],
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", " ", " ", " ", " ", " ", " ", " "],
                ["b", " ", " ", " ", " ", " ", " ", " "],
                [" ", "", " ", "b", " ", "b", " ", "b"],
                ["b", " ", "b", " ", "b", " ", "b", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"]
            ],
            [
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", "r", " ", "r", " ", "r"],
                [" ", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", " ", " ", " ", " ", " "],
                ["b", " ", " ", " ", " ", " ", " ", " "],
                [" ", "", " ", "b", " ", "b", " ", "b"],
                ["b", " ", "b", " ", "b", " ", "b", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"]
            ],
            [
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", "r", " ", "r", " ", "r"],
                [" ", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", " ", " ", " ", " ", " "],
                ["b", " ", " ", " ", " ", " ", " ", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"],
                [" ", " ", "b", " ", "b", " ", "b", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"]
            ],
            [
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", "r", " ", "r", " ", "r"],
                [" ", " ", " ", " ", "r", " ", "r", " "],
                [" ", "r", " ", "r", " ", " ", " ", " "],
                ["b", " ", " ", " ", " ", " ", " ", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"],
                [" ", " ", "b", " ", "b", " ", "b", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"]
            ],
            [
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", "r", " ", "r", " ", "r"],
                [" ", " ", "b", " ", "r", " ", "r", " "],
                [" ", "", " ", "r", " ", " ", " ", " "],
                [" ", " ", " ", " ", " ", " ", " ", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"],
                [" ", " ", "b", " ", "b", " ", "b", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"]
            ],
            [
                ["r", " ", "r", " ", "r", " ", "r", " "],
                [" ", "r", " ", " ", " ", "r", " ", "r"],
                [" ", " ", " ", " ", "r", " ", "r", " "],
                [" ", "r", " ", "r", " ", " ", " ", " "],
                ["", " ", " ", " ", " ", " ", " ", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"],
                [" ", " ", "b", " ", "b", " ", "b", " "],
                [" ", "b", " ", "b", " ", "b", " ", "b"]
            ]
        ];
       $("#checkers_anim").checkers(board_checkers_anim);


You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: WordPress Themes | Thanks to best wordpress themes, Find WordPress Themes and Themes Directory