Original Post
ok. i''m making a *simple* tiled map editor. i''m using pure win32 for the code (please don''t lecture me on using mfc or vb). here''s my problem: in my tiles sub-directory, i have all of my bitmapped tiles, and a file - tiles.txt - that contains the filenames of the tiles. but my tile loading function will only load the last tile specified in the file! code:
if my ''tiles.txt'' file looks like this:
tiles\\ground_001.bmp
tiles\\ground_002.bmp
the function will only load the ''ground_002.bmp'' file! am i just missing something little here? help would be appreciated. thanks.
HBITMAP bmp[256];
int numBitmaps = 0;
int LoadTiles(void)
{
FILE* f; // File handle to open
char fname[256]; // Current file name
int i=0;
// Open the ''tiles.txt'' file for reading
if ((f = fopen("tiles\\tiles.txt", "r")) == NULL)
return 0;
// Load the filenames into HBITMAPS
while (!feof(f))
{
fgets(fname, 96, f);
// Load the bitmap
bmp[numBitmaps] = (HBITMAP) LoadImage(GetModuleHandle(NULL), fname, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (bmp[numBitmaps] == NULL)
Message("Unable to load bitmap %s", (char*)fname);
numBitmaps++;
}
fclose(f); // Close the file
return 1;
}
|
#define ignite_software 1 |