Advertisement

Random level generator?

Started by April 12, 2000 03:28 PM
4 comments, last by DanS 24 years, 6 months ago
If any of you have played Worms, Worms2, or Worms Armageddon, do you know what kind of algorithm they used for the level generator? I have a similar game in development and desprately want to know! Please post or e-mail me. DanS
DanS
I started a Worms clone with a friend, but it never got very far.

However, I did complete the random level generator code.

This was a while ago, but I'll try to remember the important details.

For each pixel along the x-axis of the level I have a "top" & "bottom" location, the space between each is filled with whatever texture, and grass is added at the top.

To render it, I randomly select a start location (on x axis), a top and bottom location (usually very close to each other), a direction to work in(left/right), and a variable describing the current top & bottom heights using a floating point variable (so you can have smaller gradients)

For each pixel from the start location to either the end of the level:

o set top & bottom locations to the contents of the current top & bottom variables (rounded of course)

o adjust the current top & bottom variables by a small random amount (make it bias towards the current gradient, so you get nice big hills instead of a wiggly line )

o check the top is higher than the bottom etc, if they meet, exit the routine, the landscape is complete. Also quit if the top goes off the bottom of the screen.

o move along the level in the direction selected initialy.

You will also want to prevent the landscape from going off the top of the screen (or too high)

This creates a land-mass, you will probably want three or four, you will also want to add sprites on top (snowmen etc)

Each sprite had information regarding how much of the sprite could be buried etc, which was used when placing the sprites.

Not the best of descriptions, but it's not very hard to do, hell, I managed it

George.

"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"


Edited by - GEo on 4/13/00 5:47:12 AM
George. F"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
Advertisement
Hmm... im thinking of making a random world generator for my upcomming game, it''s an RPG w/ a huge 2d world...
I need to make a world w/ different types of terain (ie. snow, desert etc). The generator is not to be sent w/ the game but it''s for me so i dont have to make the entire world by myself but just edit in the towns etc.

can anyone help me?

========================
Game project(s):
www.fiend.cjb.net
=======================Game project(s):www.fiend.cjb.net
I'm planning somethin' like that for my RTS-Game, too...


CU M.E.L.O...

Edited by - Melo on 4/13/00 11:48:22 AM
Thanks GEo..you helped a lot.
DanS
Hmmm...To do this, I guess I would make each tile contain information about which kind of tiles can be adjacent to it.

For example, if I have a vertical bridge tile, it would contain information about what tiles can go above, below, left, right, etc..

So, for this example, it would say that only another bridge tile or a bridge-landing tile can go above or below, and only a water tile can go to the left or right.

This woulld work...

This topic is closed to new replies.

Advertisement