0.1.1695 • Published 7 years ago

dynamicgrid v0.1.1695

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

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

7 years ago

0.1.1694

7 years ago

0.1.1693

7 years ago

0.1.1692

7 years ago

0.1.1691

7 years ago

0.1.1690

7 years ago

0.1.168

7 years ago

0.1.167

7 years ago

0.1.166

7 years ago

0.1.165

7 years ago

0.1.164

7 years ago

0.1.163

7 years ago

0.1.162

7 years ago

0.1.161

7 years ago

0.1.16

7 years ago

0.1.15

7 years ago

0.1.14

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago