How would I make a random level generator in game?

Get help using Construct 2

Post » Wed May 23, 2012 3:49 am

I am wanting to make a game similar to the old Toejam and Earl game for Sega Genesis. I want to make a game that has the same random level generator style of levels. I want to make a small map, put some destructibles like trees randomly placed all over the map and after you destroy each tree one of them has the item or monster in it that you need to beat the level. How would I do that?? Thanks guys.
B
10
G
2
Posts: 9
Reputation: 1,137

Post » Wed May 23, 2012 6:21 pm

I don't know the games you are talking about, but in the FAQ you can see a nice example.
As you can see it is quite complex, and if you want to do something like this you will have to be quite comfortable with arrays.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu May 24, 2012 5:11 am

I don't want to randomly create new terrain or whole worlds like Minecraft or Terraria. I would like to just make the same level layout myself but make destructible objects always arranging themself in a random different sequence so that upon destroying them you will be looking for the "key" you are trying to find but it will always be in a different place. Would that be done the same way?
B
10
G
2
Posts: 9
Reputation: 1,137

Post » Thu May 24, 2012 6:39 am

Couldn't you place a bunch of spawn points and then have the system just pick x number of random spawn points and spawn various objects?
B
19
S
6
G
5
Posts: 98
Reputation: 4,484

Post » Thu May 24, 2012 3:57 pm

@kalewind1 here's how to implement the example from your last post, which will give you ideas on how to accomplish the more complicated tasks you are after:

Step 1:
Add an instance boolean called 'ContainsKey' to your 'Tree' object and set the default value to 'false'.

Step 2:
Create an object called 'TreeSpawnPoint' and place several of them all around your level wherever you want a tree to potentially show up.

Step 3:
In your events, create a new condition "System: On Start Of Layout + System: Repeat x times + System: Pick a random 'TreeSpawnPoint' instance", where x is the number of trees you'd like. As the first action to this condition, create a tree at the point (TreeSpawnPoint.X,TreeSpawnPoint.Y). As the second action, destroy the TreeSpawnPoint. So now, when it repeats, it'll select from the remaining TreeSpawnPoints and a new tree will be created at a different area.

Step 4:
In your events, create a new condition "System: On Start of Layout + System: Pick a Random 'Tree' instance. As the action to this condition, "Set Tree.ContainsKey to true". So you picked one random tree out of all your trees and said that you want it to contain the key. Great.

Now you're all set. A 'random level' will be generated and a tree will be selected to place the key in. Now when your character destroys a tree, test to see whether that tree 'contained the key' by testing 'Tree.ContainsKey'. If it does, then create the key there.

I can create a .capx later (not now), but it might be better for you to just implement it yourself, so you can really grasp what you're doing.Dalal2012-05-24 15:59:20
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Thu May 24, 2012 10:39 pm

I'm super new at this so its all kind of over my head right now but I will give this a try, thanks so much for the info!!!
B
10
G
2
Posts: 9
Reputation: 1,137

Post » Fri May 25, 2012 2:19 am

[QUOTE=kalewind1] I am wanting to make a game similar to the old Toejam and Earl game for Sega Genesis. I want to make a game that has the same random level generator style of levels. I want to make a small map, put some destructibles like trees randomly placed all over the map and after you destroy each tree one of them has the item or monster in it that you need to beat the level. How would I do that?? Thanks guys.[/QUOTE]


The following example will produce a random level (golf hole) when you press the 'create hole' button.
You might find it a bit hard to follow? but heres the capx file-

RandomHole

Good luck
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Sat Jun 02, 2012 2:05 am

Amazing example chrisbrobs.
Tips his hat.
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Thu Jan 29, 2015 10:43 pm

chrisbrobs wrote:[QUOTE=kalewind1] I am wanting to make a game similar to the old Toejam and Earl game for Sega Genesis. I want to make a game that has the same random level generator style of levels. I want to make a small map, put some destructibles like trees randomly placed all over the map and after you destroy each tree one of them has the item or monster in it that you need to beat the level. How would I do that?? Thanks guys.



The following example will produce a random level (golf hole) when you press the 'create hole' button.
You might find it a bit hard to follow? but heres the capx file-

RandomHole

Good luck[/quote]

Hi buddy. I just trying to do something like randomly created terrain, so I find this post. Can you post the project again? because the link is broken.
Thank you
Luiz
B
3
Posts: 1
Reputation: 177

Post » Fri May 29, 2015 3:55 am

randomhole capx link is broken?
B
21
S
6
G
5
Posts: 391
Reputation: 5,627

Next

Return to How do I....?

Who is online

Users browsing this forum: Renfd, supreme676 and 32 guests