By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

Easy or not?

P: n/a
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.
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
!Q

"Maximus" <ik*********@videotron.ca> wrote in message
news:gy*********************@weber.videotron.net.. .
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][i] = texture index

so to draw it you would do something like:

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

pretty static, pretty simple

!Q
Jul 19 '05 #2

P: n/a
!Q

"!Q" <sa*****@spammer.com> wrote in message
news:bp**********@lust.ihug.co.nz...

"Maximus" <ik*********@videotron.ca> wrote in message
news:gy*********************@weber.videotron.net.. .
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][i] = texture index

so to draw it you would do something like:

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

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

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.