Skip to content

1.8.1 - Multi Textures, WebGL2

Latest
Compare
Choose a tag to compare
@KilledByAPixel KilledByAPixel released this 19 Apr 17:34
· 4 commits to main since this release

New Additions

  • multi texture support!
  • improved tile indexing
  • Webgl 2.0 shaders
  • TextureInfo class tracks stuff for each loaded image
  • TileInfo is used to index into a texture
  • fix RandomGenerator
  • cleanup code

With the new system some of the functions signatures have changed because now instead of passing in the tileIndex and tileSize around, now everything is contained in this object which is more useful because tiles aren't limited to being on a grid, also it has an optional texture parameter so anyone using multiple tile sheets can just pass in the index to any texture into there.

We also have an important new function called tile() where you can pass in tile index, or vector position and pass in the size as a float instead of a vec, if it is square, this should make it easy to use and retrofit old code.

So basically if you had code like this...

drawTile(this.pos, vec2(2), 0, vec2(16));

it becomes this...

drawTile(this.pos, vec2(2), tile(0, 16);

For anyone with a large code base, you can also retrofit old code by creating a new function called drawTileOld that works the old way and calls the new drawTile using the tile function to wrap the old params if that makes sense.

TileInfo is much more useful for us because it is not limited to a grid, the tiles can be at any pixel locations. Also a texture can be passed in and littlejs will handle using the correct one.