Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/s-a/hex-board-game


https://github.com/s-a/hex-board-game

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# hex-board-game (work in progress...)

## Install with bower
```bower install hex-board-game```

## Try the test
- Open ```http://localhost/YOUR_PRORJECT/bower_components/hex-board-game/``` in browser. (some requests need a webserver so the demo cannot run from filesystem!)

Set current zoom scale:
```
game.GUI.board.zoom([INTEGER 1-8]);
```

Set current viewpoint:
```
game.GUI.board.viewPoint = {
x:-110,
y:-0
};
```

Currently there is a mockup function fetching the hex map data. You can overwrite this method to fetch your data from server.
``` javascript
(function($, game, Field) {

GUI.prototype.board.fetchData = function (ordinate, onComplete) {
var self = this;
this.GUI.$loading.show();
var rows = [];

for (var x = ordinate.x1; x < ordinate.x2; x++) {
var row = [];
for (var y = ordinate.y1; y < ordinate.y2; y++) {
var fieldParms = {
position : {
x : x,
y : y
}
};
row.push(new Field(fieldParms));
}
rows.push(row);
}

window.setTimeout((function() {
onComplete(rows);
self.GUI.$loading.hide();
}), 800);
};

})(window.jQuery, window.game, window.game.class.Field);
```

Todo; Write the docs;