Posted on June 8th, 2010
4101 views 5. Stylesheet
Now the stylesheet. I will explain on how to use spritesheets below the code dump. � html, body { � This is actually very very easy. So we now the size of our tiles which are 64x64px in our case. The div.content div.tile sets the basic attributes of all tiles, width / height, absolute position and the background image, but no positions. So it will just show the upper left of the image and cuts it after 64px height and width.
This is where the other classes will be needed (.grass_0, .grass_1 etc) Those classes will be set by the tile variable of the game map array. However those classes just have one css attribute, the background-position. So for example .grass_1 uses 64px and 0px. This will show the second image from the upper left of the tiles image. Basically you're just giving coordinates for the upper left corner of the tile. This + tiles width and height will result in the wanted tile. Sounds much more complicated than it is. I think I added enough example tiles to make this clear.
|