Am am making a wap-game that will have a minimap. It is basically a 5×5 div with (a) 20×20 pixel background image(s).
I’ve come to a stalemate trying to figure out on how to design them, though.
Making a 100×100 pixel image for each ‘location’ wouldn’t be a good idea, since if one of those 20×20 locations changed, I would have to update 15 100×100 images.
Two choices are left then:
- Combining the 20×20 pixel images to a big 100×100 pixel one using GD
- Giving each div in the minimap a background with the 20×20 location image.
In the second scenario a lot of HTTP requests would me made to fetch the images, in the first, server resources would be used to combine them to a big image.
Which of the options do you think would be a more efficient one? Basically I see it as a lose-lose situation, but one has to decide which loss is less painful.
Why don’t you check out CSS SPRITES?
http://spriteme.org/
Then you can generate the map with a php function that select the CSS class (with its relative background) randomly.
If you have let’s say 9 different parts of map 20×20, to be combined in a 3×3 grid, you just have to create a class for each piece of map. You can generate it dinamically (replace 0px 0px with a “$x = rand(0,3)*20; $y = rand = rand(0,3)*20;” or so.
1 HTTP request to be called, and no server resources to be wasted in GD!