0.1.1695 • Published 8 years ago
dynamicgrid v0.1.1695
Dynamic Grid
This is a dynamic grid for gaming.
var Grid = require('dynamicgrid');
var grid = new Grid(w, h, segment); // Segment is {w : w, h : h}
var item = grid.createItem(110, 110); // Returns Item
// Update items position
item.update(x, y) // Defaults to current x and y
// Listen when items show up in segment
item.segment.on('update', cb);
// Listen to item changing segment
item.on('segment change', cb);
// Get plain object to pass to client
item.plain();
// Destroy item
item.destroy();
// Check if x and y are within range of item
item.withinRange(x, y);
// Listen to segment group
item.listenToSegmentGroup(cb);
// Listen to destroyed items
grid.on('destroyed item', cb); // Gets passed item
// Listen to all segment changes in grid
grid.on('update', cb);
// With socket.io
io.emit('item', item.plain());
// Get all other items in segment
item.getOtherItemsInSegment(true); // True passes as param returns all of the other items plain object
// otherwise you get the full item
// Get items in surrounding segments
item.getItemsInSurroundingSegments(true); // True gets items in plain object
0.1.1695
8 years ago
0.1.1694
8 years ago
0.1.1693
8 years ago
0.1.1692
8 years ago
0.1.1691
8 years ago
0.1.1690
8 years ago
0.1.168
8 years ago
0.1.167
8 years ago
0.1.166
8 years ago
0.1.165
8 years ago
0.1.164
8 years ago
0.1.163
8 years ago
0.1.162
8 years ago
0.1.161
8 years ago
0.1.16
8 years ago
0.1.15
8 years ago
0.1.14
8 years ago
0.1.13
8 years ago
0.1.12
8 years ago
0.1.11
8 years ago
0.1.10
8 years ago
0.1.9
8 years ago
0.1.8
8 years ago
0.1.7
8 years ago
0.1.6
8 years ago
0.1.4
8 years ago
0.1.3
8 years ago
0.1.2
8 years ago
0.1.1
8 years ago
0.1.0
8 years ago