Archived

This topic is now archived and is closed to further replies.

+AA_970+

displaying tiles

Recommended Posts

i'm working on a tile based graphics engine with direct x. To plot the tiles I created a ddraw surface to place tiles on and then i blt the surface to the back buffer.

Am i using the right method to display the tiles?

Also, I've read that to create smooth scrolling you have to create and extra row and column of tiles, but a ddraw surface in vid memory only allows the surface the size of the primary surface.

Should i create the ddraw surface in system memory to hold the extra row and column of tiles?

Share this post


Link to post
Share on other sites
You only draw an extra row and column. Just clip those to the viewport, no need to make a bigger one.

For instance, in a normal 2d engine with a screen res 640x480 and tiles 32x32 you would have to have 20 columns and 15 rows.

for(row=0;row<15;row++) {
for(column=0;column<20;column++)
blittile(tile,column*32,row*32);
}

But, when the tiles scroll left and up a couple of pixels, you'll see that many pixels of empty space to the right and bottom of the screen. Simply increase the number of rows to 16 and columns to 21, then draw as normal:

for(row=0;row<16;row++) {
for(column=0;column<21;column++)
blittile(tile,column*32-xoff,row*32-yoff);
}


Jim Adams

Share this post


Link to post
Share on other sites