0
\$\begingroup\$

I am working on an end-less running game where obstacles are placed along the way on moving background. I have a lot of levels in the game,and I am implementing it using JSON.

My JSON file for first level look like this:

 "obstacles": [
 {"name":"rock","position":"middle","distance":"1000","speed":"350"},
 {"name":"crow","position":"up","distance":"1600","speed":"350"},
 {"name":"gap","position":"down","distance":"1600","speed":"350"},
 {"name":"monkey","position":"middle","distance":"2200","speed":"350"},
 {"name":"fish2","position":"down","distance":"2400","speed":"350"},
 {"name":"crow","position":"up","distance":"2600","speed":"350"},
 {"name":"snake","position":"up","distance":"3400","speed":"350"},
 {"name":"fish","position":"down","distance":"3400","speed":"350"},
 {"name":"fish2","position":"down","distance":"4400","speed":"350"},
 {"name":"monkey","position":"middle","distance":"5500","speed":"350"},
 {"name":"rock","position":"middle","distance":"6500","speed":"350"},
 {"name":"fish","position":"down","distance":"6500","speed":"350"},
 {"name":"cloud","position":"up","distance":"7200","speed":"350"},
  {"name":"rock","position":"middle","distance":"8000","speed":"350"},
 {"name":"gap","position":"down","distance":"8000","speed":"350"},
 {"name":"snake","position":"up","distance":"8700","speed":"350"}
 ]

Here I am placing obstacles up to an x position of 8700 on a moving parallax back ground.

Level1 is working fine,but my issue is that how I should place the next level obstacles.I have only one way that some position after 8700 I have to choose for placing next level obstacles.

Here I want to clarify one thing.Will it become a problem when I use larger values like this?

There is more than 20 level planned in my project,and each level get loaded automatically when one is completed.

I expect suggestions from experienced persons ,for designing the levels with these aspects.

Thanks in advance.

\$\endgroup\$
1
\$\begingroup\$

I would place objects in a procedural way. Keep track of the distance while ingame and try to spawn obstacles in intervals. Check for the current distance travelled and spawn obstacles according to it. Maybe hold level-specific obstacles in a dictionary, where the key is the minimum distance to spawn the obstacle

\$\endgroup\$
1
\$\begingroup\$

If it is an endless running game there is no point of designing all the levels. Maybe design the first 1000 meters as a tutorial, and after it use some procedurally way of generating the next objects. As you go further the shorter are the intervals of obstacles, p.e.

Anyway if u want to go with json way you can try it:

"level1": [
 {"name":"rock","position":"middle","distance":"1000","speed":"350"},
 {"name":"crow","position":"up","distance":"1600","speed":"350"},
 {"name":"gap","position":"down","distance":"1600","speed":"350"}],
"level2":[
 {"name":"cat","position":"middle","distance":"500","speed":"350"},
 {"name":"gap","position":"up","distance":"1500","speed":"350"},
 {"name":"rock","position":"down","distance":"1700","speed":"350"}]

At the moment of spawning the obstacles, multiply the current level for the distance. It will make you json more readable.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.