Hey its AJ
For those of you who dont get how tiling works, Ill try to explain it a bit here.
First of all, why even use tiles?
Well, tiles provide an easy way to detect collision, and keep file sizes down by reusing pieces. If there was one big image, how would the character react within it. (there are ways of corse). A big image is undesirable however, because if a change is needed the entire image needs to be changed opposed to a single tile. In a sense, tiling allows you to "create" a map rather just using a big image.
But... collision detection sucks!
There are ways to improve collision detection with the tiles. Besides basic bounding box collision with the tiles, angled collision is a possibility along with using 'getPixel' and checking for alpha spots.
The alpha method works, but performance can be slowed down when having do a MINIMUM of 4 point checks per object. We can, however, play around with this and see what kind of performance we can get. Reguardless of whether this will work to our needs or not, tiling will still be used.
So how does tileing work?
Basically, inside each map is a grid. Each grid spot contains one tile space. When making the map, whenever a new tile is created it will be assigned an array index number in sequential order. When generating the map itself, you just specify the tile number. For example:
The following will be a 5x5 grid. If each tile is 32x32 then the size of the map would be 32x5 or
160x160
1 = grass tile
2 = dirt tile
3 = sky tile
4 = box tile
3,3,3,3,3
3,3,3,3,3
3,3,4,3,3
1,1,1,1,1
2,2,2,2,2
Each tile will have specific properties such as whether you can or cant collide with it. So in the above example, you would want to colide with the grass and the crate, but not the sky and the dirt doesnt matter since you cant get to it.
All 2d games use tiling. 3d games do not need to do this because in a 3d world, any geometry is just that, geometry. Since it is geometry, it contains x,y,z locations with textures applyed to the surfaces. This allows us to do collision checks with the surfaces themselves. In 2d we do not have this geometry, which is why tileing is used. Tiling provides us with "geometry" since we now have an x,y and width and height we can interact with our surroundings.
I hope this gives you all a better picture of how it will work.
And sorry for jumping back and forth, im in a hurry!