Background - OxiStudios/OrbMain GitHub Wiki

Intro

So the background in this game is not a huge part, so this means that we don't want it taking up a lot of resources. Furthermore, we want it to be random. So how do we do that? Well in two steps really. The first step is generating the random indexes for an array. This array will be called every time we need a new chunk of background. If we're at the end of the array and the game is still going I think it wouldn't be the worst thing the world to repeat the array over, but I may be wrong so we will have to see. Anyways, the second part is only rendering the pieces that the screen is showing. Otherwise we are rendering way more than what we have to.

So the background class's two main functions are:

  1. Creating the random array of numbers at the start of the game
  2. Maintaining what sprites are being rendered.

Background Class

  • It will have 10 or so sprites each 1/n of the Gdx.graphics.getHeight() (n being the number of sprites)
  • Their width will equal Gdx.graphics.getWidth()
  • There will be 20 or so different segments of art that will be loaded in and each on will be assigned an index
  • There will be a random generator that will make the random array of indexes.