A long time ago, when I last tried making a game, I used to draw tiles like this… (pseudo code)
for each tile in the world
if the tile is visible
Image img = tilesheet.getSubImage(a,b,c,d); //to get the tile image from the tilesheet
... //here I use img.setColor(...) for each corner of the img, in order to setup it's colors according to it's light values
img.draw(tile.x, tile.y);
But this is an horrible way to draw things.
I tried using
tilesheet.startUse();
for each tile visible in the world
tilesheet.drawEmebedded(....);
tilesheet.endUse();
This saves me some fps, however, I can’t manipulate the colors in order to give lighting to the tiles with this.
Is there a good way to draw tiles from a spritesheet, manipulate light and save as much memory as possible?
Should I try writing a vertex shader? I’m not very familiar to shaders yet… Specially when it comes to vertex shders.
These are some examples of simple fragment shaders I have written today:
[spoiler]
(the background only /)
[/spoiler]
But if it happens for vertex shaders being the best decision, I’ll do my best to get over it.
Thanks a bunch and sorry for my bad english :clue: