jGames - display various games using jQuery

Posted on by Kenny Cason
tags = [ checkers, chess, go, jgames, jquery, othello, shogi, xiangqi ]

jGames is a collection of functions written in jQuery to display static states of various class board games, including Checkers, Chess, Go, XiangQi, Shogi, Othello, Tic Tac Toe, Cards, and Dice.

It also supports display of a series of states (i.e. an animation). This is useful when you want to show a series of moves for demonstration purposes. The time between transitions is also configurable.

As this is the first release be wary of any bugs and also keep in mind that I will be updating it continuously.

jGame links
1. jChess
2. jCheckers
3. jGo
4. jXiangQi
5. jShogi
6. jOthello
7. jTicTacToe

Below is a simple demo of some of the games supported.

Clone from GitHub!

Usage 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. “chess”. This is where the chess board will be rendered to.

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

Next, create the state of the chess board using Javascript. Depending on the game you want to display will depend on the exact configuration. More documentation can be found on each of the modules pages (Coming Soon). For Demo purposes, we are going to create the static Chess board that was displayed above

1
2
3
4
5
6
7
8
9
10
        var board_chess = [
            ["br", "bn", "bb", "bk", "bq", "bb", "bn", "br"],
            ["bp", "bp", "bp", "bp", "bp", "bp", "bp", "bp"],
            [" ", " ", " ", " ", " ", " ", " ", " "],
            [" ", " ", " ", " ", " ", " ", " ", " "],
            [" ", " ", " ", " ", " ", " ", " ", " "],
            [" ", " ", " ", " ", " ", " ", " ", " "],
            ["wp", "wp", "wp", "wp", "wp", "wp", "wp", "wp"],
            ["wr", "wn", "wb", "wk", "wq", "wb", "wn", "wr"]];
       $("#chess").chess(board_chess);
That’s it!
comments powered by Disqus