2d libgdx: runtime level generation

Posted by lxknvlk on Game Development See other posts from Game Development or by lxknvlk
Published on 2014-08-18T12:29:40Z Indexed on 2014/08/18 16:47 UTC
Read the original article Hit count: 460

Filed under:

I have encountered a problem during my first game development: I thought of a Array<Ground> groundArray that does groundArray.add when a new ground will appear on the screen, and removes oldest ground when it will no longer be seen, if player only moves to the right, like in flappy bird.

enter image description here

The perfect structure would be a queue for such a mechanic, but libgdx doesnt have one. Using libgdx's Array is not intuitive too - i have to reverse the order of elements. It has a method pop() that removes the last element, but no such method to use on the first element.

What are my options here?

  • extend Array class and add something?
  • writing my own queue-like class?

© Game Development or respective owner

Related posts about libgdx