Dynamic Map Creation

For questions about using Classic.

Post » Sun Sep 26, 2010 1:00 pm

Heya there.

I'm trying to get Construct to generate a grid of tiles, with a predefined width and height of the grid. I also need to be able to give the squares a semi-random private variable that will determine what kind of 'terrain' that they will be - dirt, stone, air, etc.

I've thought about using an array or loops to do this but I have no idea how they work. Anyone have any idea how to do this?

Thanks
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Post » Sun Sep 26, 2010 10:59 pm

[quote="cow_trix":383tebaq]I'm trying to get Construct to generate a grid of tiles, with a predefined width and height of the grid. I also need to be able to give the squares a semi-random private variable that will determine what kind of 'terrain' that they will be - dirt, stone, air, etc.

I've thought about using an array or loops to do this but I have no idea how they work. Anyone have any idea how to do this?[/quote:383tebaq]

An array would be exactly what you would want to use. And you should probably look into the Perlin Noise plugin as well, as it's great for creating random terrain and things alike.

There's some stuff about that on the forums. But for simplicity's sake I just created a very basic example, which uses an array and the perlin noise plugin to create a crude map from sprites. It's only 2 events! :)

[url:383tebaq]http://dl.dropbox.com/u/2306601/simplearraymap.cap[/url:383tebaq]
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Mon Sep 27, 2010 2:05 am

Cool, thanks! That's the first step. Now for the hard part. I want to make a side-view, "cross-section" platformer as opposed to a to top-down game, where you can destroy and create tiles. Sort of like a 2D minecraft.

That means I've got to do a few things I don't know how to do:

- Establish a "ground level" that varies with hills and mountains, etc.
- Dirt is almost inevitable at that "ground level", and get's less and less likely as the distance from the ground level increases.
- As you get deeper and deeper, you get more and more stone until stone is inevitable. Similarily for empty air.

As far as I can tell, this means creating some kind of function to replace the Perlin Noise. Any thoughts?
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Post » Mon Sep 27, 2010 11:35 am

You could still use Perlin Noise if you wanted a cave-like structure. Which I'm guessing from your description is not what you're actually aiming for.

[quote="cow_trix":s29047sc]As far as I can tell, this means creating some kind of function to replace the Perlin Noise. Any thoughts?[/quote:s29047sc]

Well, yeah. I'd say you should make up your own events to achieve this. I came up with an overly simplistic frame-controlled approach for example:
[url:s29047sc]http://dl.dropbox.com/u/2306601/mapthing.cap[/url:s29047sc]

Probably not the most sophisticated way to do something like this, but maybe it'll give you some ideas. There's so much that you can do fiddling around with Construct. :mrgreen:
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest