0

I start with a horizontal line and I run midpoint displacement algorithm to generate some mountains, then I want to place some pillars on top of the mountain by randomly choosing the X coordinate, but I need the Y coordinate of the mountain so I can place the pillar, right?

Now the idea is that these mountains will keep changing and moving, some chunks might move up or down while moving left or down, at a constant motion.

Let's say I want to place a pillar on the mountain, so I get some X coord. How do I find the height of the mountain ledge that keeps moving?

dragons
  • 206
  • 2
  • 8
  • I don't understand. What's a "displaced line"? Are its X and Y coordinates related by a one-to-one function? – Anko Mar 31 '14 at 16:02
  • @Anko First I start with a single horizontal line, then I run Midpoint Displacement Algorithm or another name would be Brownian Motion, two similliar techniques for generating terrain. My line for example looks like the machines in the hospitals that detects your heartbeat. – dragons Mar 31 '14 at 16:28
  • OK. Is this 2D? How are you storing your terrain heights? – Anko Mar 31 '14 at 16:32
  • @Anko Yes it's 2D, just like a picture of from a heartbeat monitor. I dont store the heights, I only store the points where the line gets displaced, then I connect these points. If X is random and I must find the Y of the line, should I store the Y heights from X=0 all the way X=window_width ?

    The idea here is that I create random pillars around the map, on top of the displaced line, while the line itself is displacing. Everything moves. The line keeps bouncing like waves, and the created pillars on top of it gets descended or ascended.

    – dragons Mar 31 '14 at 16:39
  • 1
    If the function initially generating a Y height from your X input is fully random, you have to store the Y for every X, or you'll never find the Y again. (If it's pseudo-random, you could regenerate the outputs if you store the random seed.) Am I missing something? – Anko Mar 31 '14 at 17:27
  • @Anko Is this the best approach, I have edited my original post, if you didn't read it please do, I tryed to explain better. – dragons Mar 31 '14 at 17:43
  • 2
    Now the answer is "depends on your mood". Store your terrain heights somewhere (a list of Ys or a dictionary from x to y, maybe?) and write or read them as needed. – Anko Mar 31 '14 at 18:12
  • @Anko is right. If you know how to draw the points, then the heights are already available to you. Just use them any way you like. It seems you are pondering the best implementation in place of trying something. – Seth Battin Apr 04 '14 at 12:56
  • 1
    Use linear interpolation to find the height. You're interpolating between the two nearest X data points. – House Apr 07 '14 at 15:25

0 Answers0