Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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..

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
    
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. –  Wouter Jun 29 '11 at 10:20
    
I went along and implemented it using dynamic meshes. Works great and far more easy than I dreamed. (only did 2d gfx before) –  Wouter Jun 29 '11 at 18:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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