Jump to content
  • Advertisement
Sign in to follow this  
slynk

Ideas for Organization?

This topic is 2950 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

Currently the way my code is set up, when the character reaches the edges of the screen or touches a special tile, the game calls load_scene() and passes 3 variables that fall through a giant if else if deciding what scene to load. Then I have a block for every level as such:


int tilesize = 16;
vector<vector<int> > map ( (screen->h / tilesize) + 1, vector<int> ( (screen->w / tilesize) + 1, 7 ) );
vector<vector<int> > c_Map ( (screen->h / tilesize) + 1, vector<int> ( (screen->w / tilesize) + 1, 0 ) );

Tileset set(tilesize,tilesize,load_datafile ("Resources\\tile.dat"), 479);

map.at(10).at(10) = 317;
c_Map.at(10).at(10) = 2;

Scene s(set, map, c_Map, screen->w / tilesize, screen->h / tilesize);

return s;


The generated scene is popped onto the scene manager and the game continues on. Well this works but the code is getting long with only 13 screens. So I was wondering if anyone had an idea for how to handle this better?

Share this post


Link to post
Share on other sites
Advertisement
You'll want to make this part of your game data-driven as well. You're already loading tile-data from a file - why not store level transitions in these level files as well? It's just a matter of storing a level name or identifier for each edge. Determining the next level then becomes a simple lookup operation.

Now, if your levels are laid out on a grid, then creating a 2D array of level filenames/identifiers is all you need. Just check the current levels coordinates on this grid, check what side the player is at, and look at the corresponding cell to determine what level to load. This, also, can be read from a file, allowing you to change this layout without having to touch any code.

Share this post


Link to post
Share on other sites
Thank you for the help. I'll have to rack my brain on how to store this stuff in a file. I'm using allegro and the grabber tool to make my .dat files. My levels are on a grid. (Well multiple ones. One for the overworld, one for each dungeon, and a single screen or small grid for each building and cave.)

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!