   Stuck on screen transitioning (general development problems)
  Hey everyone,No matter what language I try to program games in (C++ with SDL, Python, C# with XNA), I always get stuck at the same spot. I can draw text and images, get keyboard input, and run a game loop moving a character around in a single tilemap or on top of a background image, but I can never figure out how to create TWO tilemaps, or 2 "zones", and start moving around between the two, making a real 'game world'.Is there a resource I can read or some tips you have about this general programming issue? The idea of creating multiple maps or areas where different textures need to be loaded is beyond me. Where do you run the code for that new loading? Where do you run the code to get rid of all the old loaded initialized variables?EDIT:Just found the king of all tutorials - http://www.sgtconker.com/Downloads/articles/nickg/AlienAggressors.pdfThank you Nick Gravelyn for creating this. I will run through the entire thing tonight.[Edited by - Kada on October 7, 2010 4:44:57 PM]
  This type of issue can arise when you start programming too flat.  I mean this in that you have no nesting/encapsulation going on with objects owning other objects.  IE: If you are relying on global state to keep track of your level data it becomes very hard to simply swap out one level for another!It is a general OOP issue.  What you want is the idea of a level object.  Once you have one level object with no stringy dependencies all over the place you can make a list of levels (which can be loaded from disk with save/load functions) and then if you have some kind of "WorldState" concept which loads data from a level object you can swap it out like a tape deck swaps cartridges.Black boxing information and cutting dependency between objects will solve your problem...  Easier to say than to do, it requires experience and practice.   ;  You could try classes such as:TGameMap   = class   name    : string; // id name   tiles   : TTileSet; // Tiles, geometry, whatever   entities: TEntitySet; // Enemies, objects, all dynamic stuff placed in this map   mapDataFile : string; // Reference to disk file that contains tiles, entities, etc. procedure load( mapFileName : string ); // Load map from file   procedure activate; // Player starts playing this map, create entities, start a music, etcetera.   procedure unload; // Free from memory   procedure render; // Draw this map   procedure update( deltaTime ); // Update AI, triggers, music, entities, ...end;TGameWorld = class   maps    : TList; // List that contains all maps   procedure loadMapCollection( fileName : string );   function getMap( idName : string ) : TGameMap; // Find a mapend;First create a World class, which is basically just a collection of all maps. You could load the map idNames and their specific data paths from a text file. When going to a specific map, "level 1" for example, you can get it from this list and then let it load.<going to level 1>if currentMap <> NULL then currentMap.unload; // release previous mapcurrentMap := gameWorld.getMap( "level 1" );currentMap.load( currentMap.mapDataFile );currentMap.activate; // GoNow it gets a little bit more difficult when you want multiple maps active at the same time. Depends a lot on the type of game you are planning. But instead of a single "currentMap", you could have a list of "activaMaps" that contains 1 or more. When your player entity moves from map A to B, you can reavulate this list. Unload and remove the maps you don't need anymore. Load and add the new map(s) to this list. Eventually you can do this whole loading process in the background so you don't have to wait. When rendering, check which map(s) are visible and render those.That's at least one way to do it.Good luck!Rick   