Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
Level with randomized rooms

srfstudio
Registered User
Quote
2019-12-23 18:54:38

I’ve been working yesterday on a code to randomize the set of rooms and corridors in an attempt to create a randomized game level. At first I wanted a 5x5 row-grid (25 objects) but then I realized that number would be too big for what I needed so I created a very simple 5x3 (15 objects, 13 effective) template.

This is an early and very crude first draft, there are a lot of things that need to be changed and enhanced. It’s a two-pass system:
>First pass is randomizing temporary 3d objects (boxes) aligned in 5 columns / 3 rows by randomly assigning them with 3 different textures (room-a, room-b & corridor) and creating the variables for each 3d object with texture-reference code. Code takes into account if box is at corner with only one exit/entrance, passable room with two entrances/exits or link-room with 3.
>Second pass is cloning the pre-made 3d geometry (3 different objects also in 3 versions) and placing them in an appropriate places depending on the temporary-boxes references by reading their variable-values and 3d location/rotation.
🔎︎

The system is as simple as I could make it. First and last rows are randomized first and a middle row is randomized to create a link between them. I also used different rotation for the same objects, excluded the first and last object in the middle row and all temporary-box-nodes have the same name as their variables so that search for reference-box-node and reference-box-variable is extremely simplified.

If someone wants to see how it works a have uploaded the CCB file here:
https://www.newgrounds.com/dump/...

All constructive modifications are welcomed to be shared and you can, of course, use the code and geometry from CCB in your own projects. 3D models from the file are created using CC room-mesh tool and textures are royalty-free textures from Spiral Graphics website.
Cheers!


AnAverageGuest
Guest
Quote
2019-12-23 23:33:15

Can you make a random terrain generator? I need it for a game I am making.


crusly
Registered User
Quote
2019-12-24 01:11:24

@srfstudio

Man, this is really a beautiful well done work...

THANKS VERY MUCH..! for sharing this...

shure It will be very usefull for test some new ideas...




Can I ask how many hours take you to complete this example?


raulc96
Registered User
Quote
2019-12-24 11:29:51

With this test you can create a app for CCB. If you made a app to create more terrains not like in CCB a single terrain will be cool. Make a app on CCB to create more terrains not a single terrain.


srfstudio
Registered User
Quote
2019-12-24 15:27:33

@AnAverageGuest
Unfortunately that's way too advanced for my coding abilities :) I can do small logic/trick things but generating a terrain in real-time is not a small trick :) I guess that only someone with a CC Studio edition & knowledge of how the terrain tool works can do something with it.
@crusly
Cheers! Hopefully someone can make something much better with this code as a starting point.
It didn't take long, code took about 2h, modeling rooms was around 1:30h because I used CC room-mesh tool to make things faster, and then debugging everything was another 1h. So entire thing took around 5h total, not really a long process.
@raulc96
You can already have more then one terrain in level:
1. Create a level with a terrain and save it as a standard ccb file.
2. Create another level with a terrain, go to File>Import>CopperCubeScene and import the first level: now you have two terrains in one level.
3. To move the terrains go to Properties>Behavior and add 'Fly in a Circle' behavior.
4. Change behavior's Radius & Speed to '0' and use Center to move terrain around.
This works in Windows & WebGL builds, I'm not sure about MAC.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact