Page 1 of 2

Roguelike map System untiled

PostPosted: Wed May 09, 2012 2:13 pm
by LemonDROP
Hey guys, what's up?

I was wondering. Latelly I've been studying Game Design and the possibility of creating interesting mechanics. I've came to the realization that games are more interesting when they have either (or both) Customization and Randomic maps. Makes players think their tale in that little world is unique. I'm Okay with the movement mechanics, shoting, bombs and everything else. Although I must say one thing really troubles me.

How would a rogue map generator work in C2? (Not tiled, I mean.)

Say I have 300 layers, each of them with one template of map with enemies, chests, obstacles, etc. [The items out of the chests would be chosen by a random number generating event that triggers once you open it (with a key) and drop out a pre-defined "pack" of items.] Once you reach a door you'd get send to the map "below" (would acord to the minimap), meaning on the start of each floor the program would have to create a simple logic to put together adjacent maps (layers) so that the door A leads to B and B leads back to A in a chain of many other rooms.

This is what I'm using as a reference (If you've ever played Binding of Isaac, it's become one of my favorite games)

So, could someone that understands more of programming than me enlighten me about this system inside the Construct2 Event system logic ? :{

Re: Roguelike map System untiled

PostPosted: Wed May 09, 2012 5:05 pm
by LemonDROP
Bump for help please ? :{ I don't need the final thought, sugestions would already help alot, I'm just stuck and I can't think of anything else than templates of maps in diferent layers that connect eachother through door events...

Re: Roguelike map System untiled

PostPosted: Thu May 10, 2012 10:49 pm
by R0J0hound
That is an interesting idea. Get a map generator going first. Each room only needs to know in what direction the doors are. For simplicity the doors could always be at the same locations. Then have it pick a random designed room with the same exits.

Instead of having each designed room on a separate layer, put them on a separate layout, it makes it a bit simpler for designing. In my example the first thing the game does is run each room layout and save each objects position and size into a global array per room. I did this so that I can pick at runtime a room according to the directions of it's exits.

I didn't do this in my example but having the room data stored in an array makes it easy to implement loading/unloading of rooms all in the same layout, so you can have massive layouts and not have to worry about high object counts bogging down the framerate.

Here is an implementation of my ideas: ... .capx?dl=1
The bare minimum amount of rooms is 15, I used 30 so that each possible room has 2 variations.

Re: Roguelike map System untiled

PostPosted: Fri May 11, 2012 2:32 pm
by Anonymous1
I use a simple random generator for my room maps that literally generates an array that represents the tiles int he room. This doesn't have to be limited to tiles necessarily as random generation isn't overly complicated.

Your chest example would be something like Chest Clicked -> Rand Number 1-10 -> Load Array(#) value. If you have a sprite labeled reward with an animation strip (but no actual animation set) then you can use that instead of an array and reference the frame with the reward. If the chest is supposed to carry multiple objects just throw in another thing to randomly determine how many rewards from 1 to chest max size. So if the chest holds 4 things max the player will have the chance of opening it and getting 1-4 items from a pack of 1-# of frames. After that the tricky part is simply determining what those are exactly.

This is just a suggestion as I'm new to C2 still (bout a week) and I haven't toyed with how the sprite frames work when multiple instances are loaded etc, but I imagine it would produce something like what you want. It would be ideal if you could get the particular instances current frame (again this can be there) and reference it to a dictionary that holds the identities of the particular item in that frame.

Re: Roguelike map System untiled

PostPosted: Fri May 11, 2012 5:55 pm
by aridale
Ive done mine in a tiered generator.

I start on the left side of the map then randomly gen a new space either right up or down and continue til I hit the edge of the layout or run outta rooms to add (a global I set on start)

Then I have a basic shape for the level. Then I loop thru the rooms and check for rooms around it and use that to determine the bounds of the level (open space inside completely surrounded by walls).

Then I loop thru each room AGAIN and based on what kinda room it became in the last step I replace it with a random room designed to fit in that section (if its a top left corner its replaced with a room with walls on the top and left)

After thats done Ive basically created a random level MAP. Its not playable cause its just graphics of how the level looks. Then I use the rooms everything got assigned in the last step to actual generate playable rooms.

It sounds overly complex but it makes it finely tuned to control exactly how I generate the finished level.

I made this room editor to help me make the rooms I want and get the layout of the objects to be used to make the playable areas.

I use the screenshot of it to make my visual layout (the objects the player collides with arent visible) and the string it generates to create the objects when that rooms generated.

The project Im usin it for is a platformer with 160 different rooms it uses to generate the levels

Re: Roguelike map System untiled

PostPosted: Fri Oct 26, 2012 5:10 pm
by Wrangler

My browser was being retarded.Wrangler2012-10-26 17:21:04

Re: Roguelike map System untiled

PostPosted: Wed Jan 08, 2014 6:28 pm
by andreyin

Hey, sorry to bump this old thread but I've been looking into map generation and I loved your code, it does exactly what I want. I've been studying it so I can update it to use tilemaps instead of saving every wall to an array, but some parts got me really confused, like this one:

How are you adding booleans like that?? D:

Also thanks for the help!

Re: Roguelike map System untiled

PostPosted: Wed Jan 08, 2014 7:37 pm
by R0J0hound
Do you mean why? It's just packing the four booleans into one number using one bit per boolean. I could have just as well packed each boolean to each decimal place like this:

The idea was to use one variable comparison instead of four. Look in "Event sheet 1" events 5-11 for it's use.

Re: Roguelike map System untiled

PostPosted: Wed Jan 08, 2014 8:11 pm
by andreyin

Yeah, I meant why, sorry.

It's just so hard to get my head around that, I understood most of your code but this part...

I get how you're generating the map though;

1. Event sheet "load rooms" is called, new array is created, saves every wall and each exit;
2. Map is generated on "Event Sheet 1" and based on that generation, you get rooms based on the exits it has (random door that has the same number of exits of the square on the map you already generated).

I understand now that you can use booleans as 0 or 1, I had no idea.. but still, let's say that we have a room with 4 doors. That picture I posted would give a result of:


1+2*1+4*1+8*1 ?

If you add and multiply it like that how can you still know which exits exist in which room?

Sorry if that's simple, I'm not a very good programmer haha!

Re: Roguelike map System untiled

PostPosted: Wed Jan 08, 2014 10:05 pm
by R0J0hound
It's just a unique number for each combination of doors. There are 16 combinations and with the formula you'll get a value from 0 to 15 depending on the exits.

The only thing that matters with this is the same value will be calculated for rooms with the same exits. Which exits doesn't matter as long as they're the same.