Sunday, January 30, 2011

GGS simulator in JS

First I wanted to code a counterpart to Mathias Python-Tic Tac Toe in JavaScript, so we could test our Server and work with two different platforms for the game, but then I ended up writing a GGS-simular in JavaScript.

Doing so I found many WTF?:s for example having just a array with users and no getUserForId() method is retarded, every time you do something you need to iterate thru all users to find the right one.

I tried to work with the world object, the localStorage object and the users array, in order to not pollute the space I bundled them all in one GGS object.

One very odd thing came up, if you're used to programming object oriented, you use many instance variables and save there objects, etc. You can't do that if you want your game to go on after your spidermonkey instance crashed. I'm not sure how people will react to such a shortcomming.

Here is how a game on our Generic Game Server could look like: TicTacToe.js.

You can take a look at the server-simulator too, It doesn't work in IE GGS simulator

There are two instances of the game in different windows (frames), the do not talk to each other directly but via the GGS API and the simulator. In the future I want to add some stuff like random game-crashes and random latency.

Time report

Today: 14 hours

No comments:

Post a Comment