-1

I am making a cocos2d-x game, and I am trying to create terrain like this: box2d terrain generator. How can this be accomplished?

GeeGoldz
  • 187
  • 2
  • 11
  • This depends on what you want. Do you want to create the terrain, then put it in the game, or do you want the game to create the terrain? – James Westman Nov 27 '14 at 06:55
  • I want to create the terrain beforehand, it's not going to be procedurally generated – GeeGoldz Nov 27 '14 at 06:55
  • So you just need to create the image for the terrain and put it in the game? – James Westman Nov 27 '14 at 06:57
  • I'm going to be creating many levels with many different shaped terrains though. Like [this](https://static2.scirra.net/images/fresh/home/airscape-ss6.png). There must be a better way to do that than creating images for every piece of land. – GeeGoldz Nov 27 '14 at 06:59
  • Or would it be best to create the entire level in one image, then add the physics bodies to the image? – GeeGoldz Nov 27 '14 at 07:02
  • You could do that. You'd have to see how much storage space all the images would take, though. – James Westman Nov 27 '14 at 07:03

1 Answers1

0

There are definitely more options than this, but these are the ones I thought of:

  1. Use one image per level: For each level, you can create the image beforehand, then add the physics bodies. This would be simpler but take more storage space, since a large image would be needed for every level.

  2. Use a few images and repeat them: This would involve a bunch of smaller images. For example, you could have grass1.png grass2.png grass3.png, etc. Each one would be slightly different so that a pattern would not be obvious. Then you would have some other images, like dirt.png, and maybe some rocks in the dirt: rock1.png rock2.png, etc. etc. Then, the game would place the dirt image where you want dirt, maybe some grass on top, and some rocks in the dirt (or whatever you want). This would be more difficult to create, but would not take nearly as much space since each image would be used over and over. Also, if you have grass, it has the bonus of covering the rough edges of repeating a square-shaped dirt image on rounded terrain.

James Westman
  • 2,680
  • 1
  • 15
  • 20