I am using a texture atlas for my tiles. Of course I need to get the sub-images to draw them on the canvas as separate tiles. Right now I can think of two ways to implement this.
Divide the texture atlas into separate
Image
instances. Then draw them onto the canvas accordingly.Use a single image, and just draw part of it by adding extra parameters to
CanvasRenderingContext2D
's method `drawImage.
I'm not sure which is better. My thoughts were that the first option would be more manageable and flexible, since each tile is separated. What would be better? What are the ups and downs of each?