December 1st, 2012, 07:06 AM
How does Temple Run creates "unlimited" maps for the game?
Hi everyone! I'm a new app developer and I wonder how does Temple Run creates "unlimited" maps for the game? Does anyone know about it?
Any replies or help will be much appreciated. Thanks in advanced!
December 1st, 2012, 10:39 AM
It generates them randomly while the game is being played. I've never heard of that game before, but from reading a description it sounds like it basically involves running in a line and avoiding obstacles that are in your path. That would make dynamically generating the maps extremely simple.
December 2nd, 2012, 02:20 AM
Thanks for the reply.
Yeah, it basically just involves running and jumping but I was thinking of making something a little more than that, say another 2 options to choose from apart from just running and jumping.
Any ideas to that the technical aspects of drafting out the unlimited map?
December 2nd, 2012, 11:06 AM
At a technical level, they probably divide the map into blocks along one axis.
For example, consider this representation of the map from a top-down view:
This would represent a map that is 2 blocks wide by 10 blocks long. Each chunk is 1 block wide by 2 blocks tall. The player would be running along the map length-wise, from 0 towards 9.
Every time the player moves forward by 1 block, a new block is randomly generated and added to the right end of the map, after 9. Assuming the player cannot run backwards, then the left-most block can be removed from memory at that time.
When a block is generated, it randomly might have an obstacle placed. Both the type of obstacle and its position can be random. For each block, there are 2 possible positions for the obstacle in this case.
Since some obstacle placements might make it literally impossible for the player to continue, you probably need some code that makes sure the randomly generate obstacles don't create an impossible situation.
Comments on this post