🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

displaying tiles

Started by
0 comments, last by +AA_970+ 24 years, 6 months ago
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?

Advertisement
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

This topic is closed to new replies.

Advertisement