martianxx wrote: |
---|
"Also how can I encode a standard bitmap image into my file (the tile set) so that it can all be contained in a single file rather two files; the map file and tile set (.bmp file)." |
Sounds like you could use an archive. I suggest the following:
-- Convert each tile into a format that can be stored into a file, like so:
1 2 3 4 5 6 7 8
|
struct TileInformation
{
int ColourDepth;
Pixel *Graphic;
unsigned int ResolutionX;
unsigned int ResolutionY;
int BaseID;
};
|
Note: "
TileInformation::BaseID" is used to identify the tile when we need to create an instance. When you've converted each base-tile type, load each base-tile into a file. Also, for the information pointed-to by "
TileInformation::Graphic" you'd load that information after, like so:
1 2 3 4 5 6 7 8 9 10 11
|
| -------------------------- |
| Depth | Res-X | Res-Y | ID |
| -------------------------- |
| Pixel Information |
| -------------------------- |
| -------------------------- |
| Depth | Res-X | Res-Y | ID |
| -------------------------- |
| Pixel Information |
| -------------------------- |
|
-- Now, convert each tile instance into a format that can be stored into a file then export all tile instances into the same file below where you stored the base-tile information.
1 2 3 4 5 6 7 8 9
|
struct TileInstanceInformation
{
int BaseTileID;
int InstanceID;
Pixel *Graphic;
unsigned int PositionX;
unsigned int PositionY;
int BehaviourFlags; // Do something when X happens, etc.
};
|
Here's an example of a tile instance within a file:
1 2 3
|
| ----------------------------------------- |
| Base-ID | Inst-ID | Pos-X | Pos-Y | Flags |
| ----------------------------------------- |
|
Here, there's no need to export the information pointed-to by "
TileInstanceInformation::Graphic" because it's already been saved when the base-tile information was exported, so we just skip this data-member.
Here's what your file might look like after exporting all of your information:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
| ----------- |
| Base Tile 1 |
| ----------- |
| Base Tile N |
| ----------- |
| --------------- |
| Tile Instance 1 |
| --------------- |
| Tile Instance 2 |
| --------------- |
| Tile Instance N |
| --------------- |
|
When the time comes to import all of your data tile, you'd read the base-tile information first followed by the tile instance information. This way, when you load your instance information, you have the base-tile information the tile instance needs.
This isn't the best guide in the world, nor is it the most favourable, but at least you have some idea what to expect.
Wazzak