PDA

View Full Version : Moving Rooms: Substitute for Random Level Generation Memory



AlphavilleNY
September 3rd, 2010, 01:35 AM
Hey, a little while ago I asked for some help at coming up with a memory system for my platformer-game's random level generation, and while I got some interesting solutions, I wasn't able to make them work out, myself. Now, I think I've got a workaround that should do everything I need, and I've already got part of it working in principle.

What I've been doing all this time is destroying an old level map whenever I create a new one. What I'd like to do instead is merely move the old map into the opposite direction the player just went out through. I've gotten part of it working so far with this line of code, for example, when the player exits via the left side of the screen:


this._x += Stage.width;

Simple enough. Problem is, when I do this it obviously moves everything away, including the player and the new level that's just been generated. I'd like to simply move the old room, but I've been unable to make it work by simply substituting the name for my tile-map array in for "this". Somehow I need to give each map a declarable identity to move as a whole in the code, or possibly make each new map an addition to the level which is moved around the player.

I suppose what I'm trying to come up with is cellular room scrolling, or something to that effect.

AlphavilleNY
September 4th, 2010, 07:32 PM
No ideas at all? I would've thought this one was easy. I know basically what I want to do-- get my tile-based levels to move-- I just don't know how to do so. Is there a way to turn the array of tiles into a movie-clip, so they can be moved like that?

TOdorus
September 10th, 2010, 11:30 PM
What I've been doing all this time is destroying an old level map whenever I create a new one. What I'd like to do instead is merely move the old map into the opposite direction the player just went out through. I've gotten part of it working so far with this line of code, for example, when the player exits via the left side of the screen.

Do you mean like in the 2D Zelda games? Because the only reason to do it like that, is to have a nice animation. There really is no other need to have two levels active unless you need to update them at the same time. By that I mean that all rooms are updated every updatecycle.

Just use an array to store your level objects in (level objects can also be arrays).



currentlevel:levelObject = levelArray[levelNum];


Your old level doesn't get destroyed, but it doesn't take up extra memory and cpu by also displaying it while it's inactive.