How would I make a random level generator in game?

0 favourites
  • 11 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • 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.

  • 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.

  • 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?

  • 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?

  • 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.

  • 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!!!

  • 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-

    <img src="http://dl.dropbox.com/u/22173473/random%20splash.png" border="0">

    RandomHole

    Good luck

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Amazing example chrisbrobs.

    Tips his hat.

  • > 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

    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

  • randomhole capx link is broken?

  • It's a 3 year-old thread.

    Chrisbrobs doesn't visit that often nowadays, so make sure to tag him or he probably won't see this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)