AlphavilleNY
July 25th, 2010, 03:56 PM
Note-- I originally had this in the AS2 forum, but hadn't noticed this category until now. Sorry for the confusion, I'm new here...
I've been banging my head against the wall for about a month now trying to figure out how to work out what I thought would be a very simple idea. I'm making a game (in Flash 8, AS2) where I want to procedurally generate the world with a mix of memory and randomly generated levels. I can get the random-generation part fine, but the memory part continues to elude me. I've used arrays and shared objects to come create a memory system for it, and I'm sure the answer is something rather simple in one of those but... well, enough rambling.
My random level generation is pretty simple. I have a set of maps I've designed and coded to be randomly selected based on the player's position as they exit/enter the frame (don't want the player to call up a map that puts them inside a wall). The map is selected based on a number variable I call "gameLevel". At the same time, I'm able to get Flash to count which room the player is in with a variable called "roomNumber"-- it starts at Zero, and then is added to or subtracted from depending upon the direction the player goes in (I'm only dealing with the horizontal right now).
Basically, what I want to do is this-- whenever a new "roomNumber" is generated, I want Flash to remember what "gameLevel" was randomly generated, and save it. The next time that the player enters that "roomNumber", the game should load its stored "gameLevel" instead of creating a new one. Random "gameLevel" generation should only happen when a new stage is needed (ie when the current "roomNumber" is either smaller or larger than any of the previous ones).
Like I said, this is probably exceedingly simple, but if the answer's staring me in the face, then I just can't recognize it.
I've been banging my head against the wall for about a month now trying to figure out how to work out what I thought would be a very simple idea. I'm making a game (in Flash 8, AS2) where I want to procedurally generate the world with a mix of memory and randomly generated levels. I can get the random-generation part fine, but the memory part continues to elude me. I've used arrays and shared objects to come create a memory system for it, and I'm sure the answer is something rather simple in one of those but... well, enough rambling.
My random level generation is pretty simple. I have a set of maps I've designed and coded to be randomly selected based on the player's position as they exit/enter the frame (don't want the player to call up a map that puts them inside a wall). The map is selected based on a number variable I call "gameLevel". At the same time, I'm able to get Flash to count which room the player is in with a variable called "roomNumber"-- it starts at Zero, and then is added to or subtracted from depending upon the direction the player goes in (I'm only dealing with the horizontal right now).
Basically, what I want to do is this-- whenever a new "roomNumber" is generated, I want Flash to remember what "gameLevel" was randomly generated, and save it. The next time that the player enters that "roomNumber", the game should load its stored "gameLevel" instead of creating a new one. Random "gameLevel" generation should only happen when a new stage is needed (ie when the current "roomNumber" is either smaller or larger than any of the previous ones).
Like I said, this is probably exceedingly simple, but if the answer's staring me in the face, then I just can't recognize it.