I am working on a game that needs a level that is completely generated. Currently my approach is to draw textures for the levels pixel by pixel during the game (in XNA with SpriteBatch). This is too intensive unfortunately. The game has frame drops even when I only draw 1 level texture each draw cycle.

Here is an example of the current prototype. It is a simple sidescroller with the avatar swimming through a cave. The shape of this cave will alter throughout the level (textures and physics collision shapes). You can clearly see the boundaries of the level tiles in the screenshot below. These are generated just before they move into camera view.

Prototype screenshot

For inspiration I looked at PixelJunk Shooter 2. These levels are obviously not generated, but some of the levels have movement. How do you guys think they implemented it? My guess is that the level and other objects in the game are actually flat 3d models, but I am not sure..


For the generation of the cave, I would lean towards dynamic mesh generation, upon which you apply your background texture.

If your cave stays the same height throughout the whole game, you could start with the generation of a spline or a bezier curve, and convert this into vertices. Extrude these vertices for two different meshes towards the top and bottom to create the cave and calculate UVs. You obviously need to make sure the end of one mesh links up with the start of the next.

You could pre-generate a few 'screens' and generate new ones on the fly during the game.

It is also possible with tiling techniques; I would invert the idea and create just the path superimposed over the background. You could pre-define path tiles and link them together with the same screen type generation.

|improve this answer|||||
  • \$\begingroup\$ I included a screenshot of the current prototype. Generating means drawing the rock background, the water and the edge on a texture. The reason I want to generate it during the game is because it is a side scroller that will go over a long distance. Also the shape of the level will be determined by the performance of the player. \$\endgroup\$ – Wouter Jun 29 '11 at 10:20
  • \$\begingroup\$ I went along and implemented it using dynamic meshes. Works great and far more easy than I dreamed. (only did 2d gfx before) \$\endgroup\$ – Wouter Jun 29 '11 at 18:57

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.