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
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…
Thanks a lot for your attention
Best regards