Easy or not?

Q

!Q

Maximus said:
Hi,
Ok my problem is hard to explain... I'm making a directdraw based program
and of course maps. I can put texture on my map but I want to save those
information in a structure with a x, y and a texture variable assigned to
that coord in order to recreate the map over and over again. Think about it,
how would you make that structure or anything else that would do the job...?
First I came with a very stupid conclusion:
struct DDMAP
{
int x[64];
int y[64];
int texture[255];//Assume I have 255 texture in a file
};
But when I came up to save it I saw that it was impossible. Try to save
that:

x1,y1 = texture #10
x1,y2 = texture #120

See what I mean!

Thanks for any help,
Max.

const int MAP_WIDTH = 64;
const int MAP_HEIGHT = 64;

const int NUM_TEXTURES = 256;

unsigned char map[MAP_HEIGHT][MAP_WIDTH];
Texture textures[NUM_TEXTURES];

map[j] = texture index

so to draw it you would do something like:

drawTexture(x, y, textures[map[j]]);

pretty static, pretty simple

!Q
 
Q

!Q

!Q said:
Maximus said:
Hi,
Ok my problem is hard to explain... I'm making a directdraw based program
and of course maps. I can put texture on my map but I want to save those
information in a structure with a x, y and a texture variable assigned to
that coord in order to recreate the map over and over again. Think about it,
how would you make that structure or anything else that would do the job...?
First I came with a very stupid conclusion:
struct DDMAP
{
int x[64];
int y[64];
int texture[255];//Assume I have 255 texture in a file
};
But when I came up to save it I saw that it was impossible. Try to save
that:

x1,y1 = texture #10
x1,y2 = texture #120

See what I mean!

Thanks for any help,
Max.

const int MAP_WIDTH = 64;
const int MAP_HEIGHT = 64;

const int NUM_TEXTURES = 256;

unsigned char map[MAP_HEIGHT][MAP_WIDTH];
Texture textures[NUM_TEXTURES];

map[j] = texture index

so to draw it you would do something like:

drawTexture(x, y, textures[map[j]]);

pretty static, pretty simple

!Q


I may have misunderstood your question.. if a texture can go _anywhere_ and
it is not simply a tile-based approach you would store the information like:

struct TextureInf {
int x, y;
unsigned char textureRef;
};

std::list<TextureInf> textures;

then you could draw them like:

for (std::list<TextureInf>::iterator it = textures.begin(); it !=
textures.end(); ++it) {
drawTexture(it->x, it->y, textures[it->textureRef]);
}

!Q
 
M

Maximus

Hi,
Ok my problem is hard to explain... I'm making a directdraw based program
and of course maps. I can put texture on my map but I want to save those
information in a structure with a x, y and a texture variable assigned to
that coord in order to recreate the map over and over again. Think about it,
how would you make that structure or anything else that would do the job...?
First I came with a very stupid conclusion:
struct DDMAP
{
int x[64];
int y[64];
int texture[255];//Assume I have 255 texture in a file
};
But when I came up to save it I saw that it was impossible. Try to save
that:

x1,y1 = texture #10
x1,y2 = texture #120

See what I mean!

Thanks for any help,
Max.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top