Jump to content
  • Advertisement
Sign in to follow this  
Littlewillie

loading a new map

This topic is 4850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is an object that holds my world. The problem lies with the LoadMap function. I am trying to load the map, which is at the bottom of the post, into the map member of my world. So far I'm not getting anything when trying to draw the world. Assuming the Draw funtion is right, I would really appreciate anyone's input as to what I may be doing wrong here. I don't think I have fully grasped the concept of the array of pointers I've used, so I have a feeling the problem my be in the way I am handling the arrays. Thanks in advance for any replies. class WORLD{ private: int width; //world width in 64*64 tiles int height; //world height in 64*64 tiles SPRITE TileSet[10]; //10 64*64 tile images used to create world char* worldmap[]; //map of world public: //WORLD(int WORLD_WIDTH, int WORLD_HEIGHT); //constructor void Draw(OBJECT viewpoint); //draw the world around the specific object void LoadTileSet(char filename[]); //load tile images for world void LoadMap(char* map[]); //load a map for the world };//WORLD //function implementation void WORLD::LoadMap(char* map[]){ //load a map of the world //copy newmap into map for(int i=0; i<28; i++){ //for each row of the newmap worldmap=map; //copy the row to the map }//end for }//LoadMap //my function called in the main //load a map into the world object gWorld.LoadMap(map00); //here is my map static char* map00[WORLD_HEIGHT] = { "111111111111111111111111111111111111111111111111111111111111111111111", "120000100000000000000000000000000000000000000000000000000000000000001", "100000400000000000000000000000000000000000000000000000000000000000001", "100000100001000000100000000100010000100000000010001000010011000010001", "100000100000000000100000000100001000010000000100010000001100000100001", "115111111111111100100000000100100100000100000000010000000000001000001", "100010000100000100100000000100100010000010000100010000001110010000001", "100001000111010100100000000100100001000000100100000000000000100000001", "100001000001010111111111111100100000000000010100000111001111000011001", "100001000000010000000000000000100000000000000100000111000000000011001", "100005000001010100000000000000100000000000001100000000000000000000001", "141111111111111111111111111111111111111111111111111111111111111111111", "101111111111111111111110000000000000000000111111111111111111111111111", "101111111111111111111100111111111111111111111111111111111111111111111", "101111111111111111111001111111111111111111111111111111111111111111111", "101011111111111111100011111111111111111111111111111111111111111111111", "101010000000000001001111111111111111111111111111111111111111111111111", "101011111111111110011111111111111111111111111111111111111111111111111", "101011111111111100111111111111111111111111111111111111111111111111111", "101000111111111001111111111111111111111111111111111111111111111111111", "101010111111110011111111111111111111111111111111111111111111111111111", "101010111111100111111111111111111111111111111111111111111111111111111", "101010111111001111111111111111111111111111111111111111111111111111111", "101010111111011111111111111111111111111111111111111111111111111111111", "101010111111011111111111111111111111111111111111111111111111111111111", "100000000000000000000000000000000000000000000000000000000000000000001", "100000000000000000000000000000000000000000000000000000000000000000001", "111111111111111111111111111111111111111111111111111111111111111111111" };//map00

Share this post


Link to post
Share on other sites
Advertisement
If the problem is in the LoadMap() function, you're more likely to get a response if you actually post the implementation of that function.

Also, you ought to post what you've already done to find the problem, and what you've observed. For example, have you stepped through the LoadMap function using single-stepping in the debugger?

Share this post


Link to post
Share on other sites
I think it's there.. Your problem is probably this:
char* worldmap[];

That will not allocate the memory you need..

worldmap=map;

That will not copy the row.. It'll copy a pointer to the row.. Which I doubt is what you really want..

Share this post


Link to post
Share on other sites
My LoadMap function implementation was in my post, I guess I didn't make that clear. However, your going to love this, there was no problem with the function or the way I set it up. The function was in fact in my Draw function.
LOL

Thank you for your suggestions. I really do appreciate it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!