Terrain generator

venificus
01-08-2001, 08:47 PM
i am making a random terrain generator (rtg) for a game and i was wondering what if any sugestions you may have for this project.. no code please only pseudo code and sugestions..
THANX!

chris1234
01-09-2001, 02:20 AM
hullo
If I was doing that I would use the dim statement and have it like this:
Dim x (100, 100) ' and thats like a map and each no. is a tile
for i = 1 to 100
for j = 1 to 100
y = A random number beetween whatever and whatever
x(i, j) = y
next
next

and then whenever you need to know what tiles were on the map you could go:

for i = 1 to 100
for j = 1 to 100
if x(i, j) = 1 then
whatever
end if

if x(i, j) = 2 then
whatever
end if

if x(i, j) = 3 then
whatever
end if

and so on

next
next


and um yeah.

zircher
01-11-2001, 10:34 AM
Chris wrote:
>
> If I was doing that I would use the dim statement and have
> it like this:

To take Chris's idea one step further...

Dim x (100, 100) ' and thats like a map and each no. is a tile
Dim h as integer

for i = 1 to 100
for j = 1 to 100
y = int(rnd()*11)-5 ' random _offset_ to some neighboring terrain

if i = 1 or j = 1 then
h = 0 ' a default height for the north and west sides
else
h = int( (x(i-1, j)+x(i, j-1))/2) ' average height of north and west
end if
x(i, j) = h+y
next j
next i

n30n
01-11-2001, 10:47 PM
hey.

I was just looking at your code 'cause i'm trying 2 write my own game (maybe have an in built rtg) , your main problem is that if the tiles have really specific tiles like a corner of a lake then the way you have your code, you could have the corner of a lake in the middle of a grassy plain. of course, your way would work if he just had very plain non-specific tiles, but otherwise you would need to have a more complex algorithim to sort it out...

I suggest using your method to build the skeletal structure of the map, and then have your program look for areas that are mainly the same, like a water area, then fill in the other tiles in the area & replace the edges of the lake with the relevant edge tiles so that it looks & works properly.

- n30n

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum