PDA

View Full Version : The faster way



xGTx
08-10-2004, 05:00 AM
Im trying to figure out the fastest way for my procedure, let me explain...

I'm using Omega for my graphics library and it uses Direct 3D. And my game is 2D; tile based. So the large tile texture i wish to use in my engine gets split up into 512x512 texture's to fit in the video memory successfully. The problem is, when im going to place a tile from a tile id there are 2 ways i think of doing it.

1) Currently wich im doing is: Just calculating how many texture sheets in the array that particular number would be in and using the remainder to find where in that texture the tile is.

2) Calculate or... Pre-Store wich texture it would be in and just use something like: Tile[Ground.TextureLoc].Draw(x,y,Ground.TextureID);

If this doesnt make sense, re-read it a few times and imagine it in your head, you'll get it. Thanks for the help!

Paulius
08-10-2004, 09:03 AM
You should precalcultate everything you can, unless it involves just additions and bit operations.

xGTx
08-10-2004, 06:13 PM
So it would be faster to have a type like:

Ground = record
GroundID : Integer;
TextureID : Integer;
end;


?

Paulius
08-10-2004, 09:43 PM
Yes. How are you storing you?¢_Tre sprite data anyway? Usually people have a list of objects(or records) of sprite definitions with properties like is collidable, is transparent, etc; and keeping, image number, x, y, width, height among them is natural, then tiles on the map itself only have to contain pointers to those definitions.