[Help] Procedural Dungeon Generator

For questions about using Classic.

Post » Tue Jul 21, 2009 3:42 am

Alright, so I have some experience with procedural dungeon generators and I figured this would make an excellent starting point for a Construct project. My problem is I'm still learning the interface and I don't know a lot of the built-in variables. I'll update this thread with questions as they arise instead of making new ones, but for now let's handle it one at a time.

I have two 32x32 tiles (to signify a wall and a floor) and I'm trying to fill the room with wall tiles to start. In the Event Sheet Editor I set a CurX and CurY variable, then I'm attempting to loop a number of times equal to the width and height of the room divided by 32. I can't figure out how to get the loop to run according to the size of the room. I've tried "Width / 32" as a parameter, but that didn't work.

After I determine the width and height of the room, I will increase CurX or CurY accordingly and place a tile at CurX * 32, CurY * 32 for each iteration.

EDIT: ehh, I made some progress using 'layoutwidth' and 'layoutheight' as the parameters for the number of iterations. I'm not sure if those are correct, though. I also cannot figure out how to nest the loops for the life of me.
B
2
G
3
Posts: 68
Reputation: 986

Post » Tue Jul 21, 2009 4:13 am

this is how I'd fill the display with wall tiles
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Tue Jul 21, 2009 4:19 am

Does the LoopIndex start at 0 or 1? Thanks for the help, though, this did work.

EDIT: I'm still playing around. I've set up a variable to be either 0 or 1 and I'd like to create either a Tile1 or Tile2 object depending, how do I do this within the loop?
B
2
G
3
Posts: 68
Reputation: 986

Post » Tue Jul 21, 2009 5:21 am

yeah the loop starts with 1 which is why I put a -1 in the positioning thing so that I could get it to 0.

Not sure what you mean exactly in the edit, but if you want to create 2 types I guess you could do it this way
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Tue Jul 21, 2009 11:56 am

At least to me, using the Array object would make things clearer. Arrays have the For Each element condition you can use to cycle through them and do whatever you like. You can check the values with the Array.CurrentX and CurrentY expressions.

So to make your map filled with walls, you'd use something like this:
[code:2r9c38bf]
For Each element -> Array: Set index (Array.CurrentX, Array.CurrentY) to 1
[/code:2r9c38bf]

And to draw your tiles:
[code:2r9c38bf]
For Each element
-> Value at (Array.CurrentX, Array.CurrentY) equal to 1
-> -> Create Wall at (Array.CurrentX * 32, Array.CurrentY * 32)
[/code:2r9c38bf]

Note that Arrays range from 1 to whatever you specify in their properties.
So there's no element [0,0] etc.

Edit: Made a lil' example: [url:2r9c38bf]http://files.getdropbox.com/u/1496418/MapArray.cap[/url:2r9c38bf]
B
3
G
3
Posts: 12
Reputation: 899

Post » Tue Jul 21, 2009 12:51 pm

thats a fair awesome aproach eyeguy
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Tue Jul 21, 2009 7:24 pm

[quote="alspal":34qc6iui]thats a fair awesome aproach eyeguy[/quote:34qc6iui]

Hehe, thanks. It's just something I happened to be working on. :wink:
B
3
G
3
Posts: 12
Reputation: 899

Post » Tue Jul 21, 2009 8:11 pm

[quote="Eyeguy":13p4ykug]At least to me, using the Array object would make things clearer. Arrays have the For Each element condition you can use to cycle through them and do whatever you like. You can check the values with the Array.CurrentX and CurrentY expressions.

So to make your map filled with walls, you'd use something like this:
[code:13p4ykug]
For Each element -> Array: Set index (Array.CurrentX, Array.CurrentY) to 1
[/code:13p4ykug]

And to draw your tiles:
[code:13p4ykug]
For Each element
-> Value at (Array.CurrentX, Array.CurrentY) equal to 1
-> -> Create Wall at (Array.CurrentX * 32, Array.CurrentY * 32)


[/code:13p4ykug]

Note that Arrays range from 1 to whatever you specify in their properties.
So there's no element [0,0] etc.

Edit: Made a lil' example: [url:13p4ykug]http://files.getdropbox.com/u/1496418/MapArray.cap[/url:13p4ykug][/quote:13p4ykug]

I've actually already gone ahead and done that, although I've run into a problem. I seem to have a memory leak or infinite loop because it starts using up 500+mb of ram fairly quickly. Does the For Each event continue to run over and over?

Also I tried looking at your example, but it said that it was made using a newer version (despite the fact I have the newest stable release).

Edit: Using the Run Once condition for the For Each element condition seems to have stopped the memory usage from climbing leading me to believe my speculation about it continually running is correct. However I still notice that, despite the program isn't doing anything particular, CPU usage is 40% (E8200, 2.66Ghz Core2Duo) and it is using about 130mb of RAM (this is steady now that I have fixed the previous issue). These numbers seem very high considering it is idling.

Edit2: *image removed, I changed the Sampling from Linear to Point and this dropped CPU usage to 5-6% and only 13mb of ram. When I change it back to Linear is uses a constant 40-50% CPU and 130mb of ram, again, despite the program not doing anything? This seems very odd. GPU is an 8800GT.
B
2
G
3
Posts: 68
Reputation: 986

Post » Wed Jul 22, 2009 6:50 am

[quote="Farmrush":vv7amxlb]
Also I tried looking at your example, but it said that it was made using a newer version (despite the fact I have the newest stable release).
[/quote:vv7amxlb]
Yeah I just realized I made the example on 0.99.4 (an unstable build). I cba to redo it on another version so I'll just post pics of it instead :D

[url:vv7amxlb]http://www.hdimage.org/images/8rok494gcu7b6uczl03.png[/url:vv7amxlb]
[url:vv7amxlb]http://www.hdimage.org/images/vbxzi1ehghw80ybzml1.png[/url:vv7amxlb]

(My pictures are always too big!)

[quote="Farmrush":vv7amxlb]I changed the Sampling from Linear to Point and this dropped CPU usage to 5-6% and only 13mb of ram. When I change it back to Linear is uses a constant 40-50% CPU and 130mb of ram, again, despite the program not doing anything? This seems very odd. GPU is an 8800GT.[/quote:vv7amxlb]

I'm not sure what's causing this on your end. The example I posted uses linear sampling and it's not really using much resources at all on my end. I have a 8800GTS.
B
3
G
3
Posts: 12
Reputation: 899

Post » Wed Jul 22, 2009 7:43 pm

Here's what I currently have:

Code
[url:1v4wp73j]http://pub.gamingw.net/39880/procgen1.jpg[/url:1v4wp73j]

Output
[url:1v4wp73j]http://pub.gamingw.net/39880/procgen2.jpg[/url:1v4wp73j]

I don't get it!

I've tried using DungeonArray.SizeX and SizeY to determine the outer edge, but that has no effect.
B
2
G
3
Posts: 68
Reputation: 986

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest