Friday, December 21, 2018

mathematics - 2D helicopter game, how to create corridor walls?


I'm looking into adapting the classic "helicopter" game (i.e. http://www.addictinggames.com/helicopter.html), 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.



Answer



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.



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...