I tried the gamedev search but it wasnt working? - Anyway i (think) I Know how this is done, but what i want to know is how is it managed? If there are 4 pics inside my image, and i would have to write
To pick out one pic, But what i want to know is there an easier way of doing this without having to keep track of all the points.
Because the if its that way i'd have to write out a differnt function for each quad i draw?
Well, what exactly are you doing? Making a tile engine? If it is something like that, and you have multiple images in the same file that have the same resolution, you can assign a number to each tile so that you can use it to figure out the location of each image in the texture. It is hard to explain, so lemme see if I can dig up some old code.
EDIT: Ok, forget the source, it is too messy to deal with. Instead, look at this:
Pretend we have a texture that hold 4 * 4 images. We know that there are 16 images. If we name the images 0,1,2,3...starting from the top left corner and moving right until we reach the end, then move to the next line, we would have something like this:
What I have done is divided our texture up with those horizontal and vertical lines and labeled each horizontal line with the percent of the texture that it starts at. Now, take a look at our number, 5. You can see that the top y value for it lies on the 25% line. This means that it starts at 25% of our texture. Since texture coords are all on a 1*1 scale, we know that our image starts at 25%, or, .25. This is the top y value. To get the lower one, just look at the lines...It would be at 50%, or .5 The same thing is done to get the x values. Now, all you need to do is to come up with a simple algorithm to tell which row or column your image is on based on the number.
This is how I have done it in the past...It is really simple once you get a clear picture of what is going on...My grade A ascii art should help out. If you really want to destroy your mind with my uncommented code, simply tell me. [smile]
[Edited by - tHiSiSbOb on December 5, 2004 5:41:59 PM]
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
Well i want to know how because it would be better than the way im doing it know - and when i do im going to start a new project to try it out. That code would be great, Thanks :D