gl-basic-tile-map
Simple 2D tile map renderer in WebGL.
Example
var shell = var ndarray = var tileMap = var createTexture = var glm = var createTileMap = var mat3 = glmmat3 var tiles = var cameraPosition = 00var cameraScale = 001var tileMap shell shell shell
Try it out now in your browser
Install
npm install gl-basic-tile-map
API
Constructor
var createTileMap =
var tileMap = createTileMap(gl, tileSheet, tileData, tileShape)
Creates a tile map object.
gl
is a handle to a WebGL contexttileSheet
is an instance of agl-texture2d
objecttileData
is an[m,n,2]
shapedndarray
tileShape
is a length 2 array describing the size of each tile
Returns A TileMap object
TileMap Methods
tileMap.draw(view)
Draws the tilemap with the given view matrix. view
is a homography represented by a 3x3 matrix giving the transformation from the world coordinates to the viewing frustum, which is in the coordinate system [-1,1] x [-1,1].
tileMap.update(data[, x, y])
Updates a region of the underlying tileIds.
data
is an ndarray containing the new pixels to updatex
is the x-offset of the region to updatey
is the y-offset of the region to update
tileMap.dispose()
Releases the resources associated with the tile map object.
Credits
(c) 2013 Mikola Lysenko. MIT License