#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    8
    Rep Power
    0

    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!

    Regards,
    Andrew
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    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.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    8
    Rep Power
    0
    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?
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    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:
    Code:
    |----------|
    |          |
    |          |
    |----------|
     0123456789
    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

    • Daniel Jones agrees
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo