2d lanscape generator Blitz3d to BMAX

BlitzMax Forums/BlitzMax Programming/2d lanscape generator Blitz3d to BMAX

DREAM(Posted 2008) [#1]
Hi i am messing around with random land generation, i took this piece of code of an archive here , it used to make a square heightmap image, i just took one x position and used the heights it genearated to make the 2d version, simple yes....anyway this seems to owrk all fine here is the code in blit3d


so now i thought i got the basic idea of whats actually going on nice curvy landscapes rather than the general jerky stuff, i thought i would try and convert it to BMAX



it generates 3 perfectly flat landscapes....

I know it has something to do with the perlin noise as the au value is the same no matter what....anybody got any ideas....its something brain achingly simple i just cant see it.......


Vilu(Posted 2008) [#2]
I get an unhandled memory exception when compiling in debug mode, complaining about accessing an array out of bounds on the line
map[x, v] = nextpoint(v)


Compiling in debug mode can often steer you to the right direction.

After fixing the issue I also noticed that your pseudo random noise function doesn't seem to use the bitshifted variable 'm' for anything.

I wish I had more time to look into this. I'm also currently implementing procedurally generated content to my game.


Gabriel(Posted 2008) [#3]
One thing that immediately springs to mind is that BlitzMax arrays are zero-indexed, and so you have to go from 0 to size-1 not from 1 to size. ( Blitz3D is very lax in this regard as they are zero indexed still but it creates the array one bigger than you require just in case you forget.)

Possibly And should be changed to & because BlitzMax uses that for bitwise operations.

Anyway, I quickly hacked up a conversion, and got this:



Is that what it's supposed to look like? I don't have B3D installed so I can't compare.


DREAM(Posted 2008) [#4]
yep this is what it is supposed to do thanks, seem apart from the array issue it was a few int to float and vice versa conversions that had me stumped, elsewise its pretty much the same......think we should add it to the archives as a 2d land geneartion, as its stored in an array i imagine it could be used to make destructible aka worms style landscapes.....