Designing an end-less running game with levels-using LibGdx JSON

by Niranjana   Last Updated July 17, 2017 06:13 AM

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.

Tags : libgdx


Answers 1


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

Raildex
Raildex
July 17, 2017 05:40 AM

Related Questions


Libgdx with Scala: Overwrite listener

Updated April 05, 2015 00:05 AM

Set the camera to follow a TextureRegion

Updated June 14, 2015 02:05 AM

How to use world coordinates

Updated June 23, 2015 02:05 AM

Does the LibGDX AI extension work on IOS?

Updated July 03, 2015 13:05 PM