jOthello is one module within the jGames suite used to display Othello game states, as well as animations. jGames can be downloaded from the jGames home page.
Display Static Othello 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. “othello”. This is where the othello board will be rendered to.
1 | <div id="othello"></div> |
Next, create the state of the othello board using Javascript. The below state represents every piece in the Othello game and renders the othello above left othello board.
1 2 3 4 5 6 7 8 9 10 11 | var board_othello = [ [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", "b", " ", " ", " ", "w", " "], [" ", " ", "b", " ", " ", "w", " ", " "], [" ", "b", "b", "b", "w", "w", "w", " "], [" ", " ", "b", "w", "w", " ", " ", " "], [" ", "b", "w", "w", "w", "w", " ", " "], [" ", "w", " ", "w", " ", " ", " ", " "], ["w", "b", " ", "w", " ", " ", " ", " "]]; $("#othello").othello(board_othello); |
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 othelloAnimator() function. Below is the code to render the above right othello 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 | var board_othello_anim = [ [ [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", "b", " ", " ", " ", "w", " "], [" ", " ", "b", " ", " ", "w", " ", " "], [" ", "b", "b", "b", "w", "w", "w", " "], [" ", " ", "b", "w", "w", " ", " ", " "], [" ", "b", "w", "w", "w", "w", " ", " "], [" ", "w", " ", "w", " ", " ", " ", " "], ["w", "b", " ", "w", " ", " ", " ", " "] ], [ [" ", " ", "w", " ", " ", " ", " ", " "], [" ", " ", "b", " ", " ", " ", "w", " "], [" ", " ", "b", " ", " ", "w", " ", " "], [" ", "b", "b", "b", "w", "w", "w", " "], [" ", " ", "b", "w", "w", " ", " ", " "], [" ", "b", "w", "w", "w", "w", " ", " "], [" ", "w", " ", "w", " ", " ", " ", " "], ["w", "b", " ", "w", " ", " ", " ", " "] ], [ [" ", " ", "w", " ", " ", " ", " ", " "], [" ", " ", "w", " ", " ", " ", "w", " "], [" ", " ", "w", " ", " ", "w", " ", " "], [" ", "b", "w", "b", "w", "w", "w", " "], [" ", " ", "w", "w", "w", " ", " ", " "], [" ", "b", "w", "w", "w", "w", " ", " "], [" ", "w", " ", "w", " ", " ", " ", " "], ["w", "b", " ", "w", " ", " ", " ", " "] ], [ [" ", " ", "w", " ", " ", " ", " ", " "], [" ", " ", "w", " ", " ", " ", "w", " "], [" ", " ", "w", " ", " ", "w", " ", " "], [" ", "b", "w", "b", "w", "w", "w", " "], [" ", " ", "w", "w", "w", " ", " ", " "], [" ", "b", "w", "w", "w", "w", "b", " "], [" ", "w", " ", "w", " ", " ", " ", " "], ["w", "b", " ", "w", " ", " ", " ", " "] ], [ [" ", " ", "w", " ", " ", " ", " ", " "], [" ", " ", "w", " ", " ", " ", "w", " "], [" ", " ", "w", " ", " ", "w", " ", " "], [" ", "b", "w", "b", "w", "w", "w", " "], [" ", " ", "w", "w", "w", " ", " ", " "], [" ", "b", "b", "b", "b", "b", "b", " "], [" ", "w", " ", "w", " ", " ", " ", " "], ["w", "b", " ", "w", " ", " ", " ", " "] ] ]; $("#othello_anim").othelloAnimator(board_othello_anim, 1000); |

Posted in
Tags: 

[...] be updating it continuously. jGame links 1. jChess 2. jCheckers 3. jGo 4. jXiangQi 5. jShogi 6. jOthello 7. [...]