KilledByAPixel / LittleJS

LittleJS is a fast HTML5 game engine with many features and no dependencies. 🚂 Choo-Choo!
Other
3.35k stars 172 forks source link

Improve tile indexing #63

Closed KilledByAPixel closed 7 months ago

KilledByAPixel commented 10 months ago

Currently users set what tile in a texture by passing in a size and tileIndex to the drawing functions.

This is not ideal because all tiles must be on a grid, and really there should be a texture tile class that handles this. This allows better organization for more complex games so the tile information can be setup in a more central location or created dynamically.

The plan is to create called a new class TileTexture, that holds the uv and size of a tile. The constructor will take a size and tile index so by default it is easy to retrofit with the current system. There will also be functions to set exact pixels for the tile, to support cases where the art is not on a grid. There will also be a function to offset the tile on a grid for animation systems.

KilledByAPixel commented 7 months ago

This is now fixed with the TileInfo class!

commit: https://github.com/KilledByAPixel/LittleJS/commit/fc46747c2a2450d10ffd94f33734d2e0b23f889d