tile map help

Started by
4 comments, last by djsteffey 23 years, 10 months ago
I am having trouble with a tile map. I have loaded all my tiles as one bmp file into video memory. I dynamically created a map size however big i want it. I have set up differnt RECT structs for each tile. My map holds indexes to an array of RECTs. So if the position on the map is 1......then I blit from RECT[1] to that position on the map. So here is the prob, when i go to scroll my map, it gives me a blurred effect. If I use a small map, say 20 by 20 this doesn''t happen. But when I use something larger like over 30 by 30 it gives me a blurred effect when I scroll it. When I am not scrolling, however, it blits just fine. Anyone know how to fix this ? Or even understand what I am saying ?
Advertisement
Umm, I''m not completely clear on how you are loading your
maps/tiles there, but the blurring thing sounds like a
performance issue - when your map is too big the frame rate
drops too low and you can notice it.

post more details pleez!


----------
Disco Love For Everyone
----------"i think that all this talking and such is paining my head to astounding annoyance" - Erick"Quoting people in your tag is cool. Quoting yourself is even cooler" - SpazBoy_the_MiteyDisco Love For Everyone
my map file is actually a text file and looks like this

4 4
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1

my program reads in the first two numbers and creates a 2D array of ints. The rest of the numbers are indexes into an array of tiles that it reads into the map array.

my tiles are one big bmp file that i load onto a direct draw surface......
then i create an array of RECTs like this
RECT tiles[num_tiles];
and then set up these RECTs to hold the coordinates and size of each individual tile inside my one big direct draw surface;

then to draw the map i do this
for (int i = 0; i for (int j = 0; j blit(from tile_surface at RECT[map[j]] to
screen at the proper position);

how this works: map[j] is an int which is what tile index it read from the map file at position width = i and hieght = j which is basically the x, y position<br><br>It might be a performance issue but i would like to think not…….i am on a 366MgHz, i only have 4MB video ram but the only thing i am loading into video ram is the tile bitmap. I am using 16bpp so i guess i could drop down to 8 bpp and see if it fixes it and if it does then i guess performance is my prob. If you know a better way to do it then enlightne me please.<br> </i>
The above message messed up my code.....here is how i draw the map

for (int i = 0; i for (int j = 0; j blit(from tile_surface at RECT[map[j]] to
screen at the proper position);
still messed it up ? what gives ?

for int k = 0; k less then width; k plus plus
for int j = 0; j less then height; j plus plus
blit(from tile_surface at RECT[map[k][j]] to
screen at the proper position);
Yah, it sounds like a performance problem.

Remember you only need to paint the tiles within the screen. So if you have a map of 255 x 255 (I''ve used these in games I wrote on a 486DX4-100Mhz) you only paint the something like 15 x 15 tiles that fit on the screen. Even in 16bpp you should be totally fine on a 366Mhz machine of any type! Also it could be your scrolling code or your monitor.

Your not on a laptop are you? They typically have slow refresh rates.

Good luck!
See ya,
Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949

This topic is closed to new replies.

Advertisement