Map Editor

After successfuly solving my problem(with the help of u guys), with the maps,
and tiles, and … forget it… I’m working on a map editor…
I’m using c/c++ and SDL.
first i have a function that opens the map file:
bool Load_Map(char *filename){

char c;
int y=0, x=0;

FILE *f = fopen(filename, "rb");

cout << "Loading map .....";

while((c = fgetc(f)) != EOF) {
    if(c=='\n') {
        y++;
        x=0;
        continue;
    }
    map[y][x++] = c;
}
cout << "ok" << endl;
return true;

}

and then i have the function that draws the map its located right after input
handling. The code:
for(int y=0;y<MAPHEIGHT;y++)
{
for(int x=0;x<MAPWIDTH;x++){

            int i = map[y][x];

            if(i==0){ Draw_BMP(x * TILESIZE, y * TILESIZE, image); }
            if(i==1){ Draw_BMP(x * TILESIZE, y * TILESIZE, image2); }
            if(i==2){
                Draw_BMP(x * TILESIZE, y * TILESIZE, image);
                Draw_BMP(x * TILESIZE, y * TILESIZE, image3);
            }

        }
    }
    SDL_Flip(screen);

It’s the same method i use to draw the map on my game… but it doesn’t seem
to work right with the editor, i just get a black screen :confused:
my map is a char map[10][10] and i’m using 32x32 tiles. I’ve tryied
everything… it’s seems that something is crashing SDL… :frowning:

Thanks a lot for your attention
Best regards

After successfuly solving my problem(with the help of u guys), with the maps,
and tiles, and … forget it… I’m working on a map editor…
I’m using c/c++ and SDL.
first i have a function that opens the map file:

while((c = fgetc(f)) != EOF) {

map[y][x++] = c;

and then i have the function that draws the map its located right after input
handling. The code:

int i = map[y][x];

            if(i==0){ Draw_BMP(x * TILESIZE, y * TILESIZE, image); }
            if(i==1){ Draw_BMP(x * TILESIZE, y * TILESIZE, image2); }

Does the file in question actually contain bytes 0, 1 and 2 (0x00, 0x01, 0x02),
or the characters “0”, “1” and “2”?

If the latter, you need to change your “i==” tests to look more like:

if (i==‘0’) …

This seems really off-topic for the SDL list…On Thu, Jan 05, 2006 at 02:22:51AM +0000, Thiago Nunes Leite wrote:


-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/