Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking into adapting the classic "helicopter" game (i.e., but I haven't yet figured out how to create the walls-generation engine.

Any pointers into the pseudocode? I'm not so interested in the objects in the middle- only the methodology for generating the sides in a way which increases with difficulty (closes in more, has more unexpected curves) as the game progresses.

share|improve this question
Also- to clarify, I need the walls to be more curvy than blocky, since they will actually be "water waves"... – davidkomer Jan 10 '12 at 7:51
just do as blocks, but smooth interpolate between each then. – Gustavo Maciel Jan 10 '12 at 8:14
up vote 17 down vote accepted

You could use 1D Perlin noise for that. Here's an image of 2D noise. I took samples where the red line is and multiplied them with some constant to get the green line.

2D noise with 1D section

The constant you multiply the values with is going to determine the height of the noise. So you could easily ramp up the difficulty. Another benefit of Perlin noise is, that it can generate tileable noise, so that you can build a seemingly endless level.

If you want to create a bottom and a ceiling, it's important that you don't generate any impassable areas. The easiest way would simply be to use the "upper" part of the noise (eg. 1.0 - noiseValue) as ceiling and the lower part (noiseValue) for the bottom (with some offset in between of course). If that's looking too dull, you could also consider two close samples, eg. imagine another red sample line one or two pixels up or down. This will give a similar, but not identical wave.

share|improve this answer
Wow, this was such a help! Thank you :) I'm developing in Flash/Actionscript- and I see there is a built-in perlinNoise function... will play with it and see how it goes :) – davidkomer Jan 10 '12 at 17:09
@davidkomer I'm glad this is useful. In flash you'll have to create a BitmapData object and use its perlinNoise function. The bitmap can be 800x3 pixels or something extreme, then you could simply extract the top and bottom line values (something like (bitmap.getPixel(x,y) & 0xff) / 255.0 should give you values in the 0..1 range. – bummzack Jan 10 '12 at 17:37
Hmmm- I got it working, but the constant/multiplier pushes the values into impassable areas... here's my code, any ideas? (vect is a vector of 32 bit values, sampled from the line of perlin noise... so y_val is just the blue channel multiplied by scaler) for(idx = 0; idx < vect.length; idx++) { y_val = (vect[idx] & 0xFF) * scaler; drawData.fillRect(new Rectangle(idx, drawData.height - y_val, 1, y_val), 0x0000ff); drawData.fillRect(new Rectangle(idx, 0, 1, y_val), 0x0000ff); } – davidkomer Jan 10 '12 at 18:17
I gotta run for now- but something tells me I just need to read your comments more carefully ;) This is where I'm at so far- – davidkomer Jan 10 '12 at 18:24
What is the scaler? The values you get will be in the range of 0..255 in your code. – bummzack Jan 10 '12 at 18:24

protected by Community Jun 22 '15 at 14:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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