Procedurally Generated Content in Crooked

This forum is currently in read-only mode.
0 favourites
  • Much like the original discussion of procedurally generated content at the Game Developer's Conference by Will Wright was an excuse for him to show off Spore, this is going to be an excuse for me to show off my work.

    I'd asked a few months ago if dynamically generated content was possible in Construct and got some mixed took me a few months to nail the game idea, which obviously has a bearing on progress towards completing it. Needless to say, after nailing the aforementioned idea, and realizing my game was going to be set in the modern era - 1930's to now possibly - not sure exactly when - I set off to make a city generator.

    The entire map is held in a 100x100 square array which I feed into a loop to display on the screen. The sprites you see are just 10x10 pixel sprites of solid colors, eventually I will make them about 128x128 and give them art.

    The generation process consists of four steps. First I fill the array with blanks, pretty simple. Second is the longest step - the roads. I start out by making a dual lane highway, which right now will always form a cross. Eventually there will be the possibility of straight and maybe turning highways. Then the program will pick a random highway or road, decide what directions are possible for it to go from that point, then branch off in a possible direction and keep going in that direction until it hits something - another street or the boundary of the map. A process which is a lot easier said than done in Construct events. This process will loop about 20-40 times until you get a grid similar to the one you see. The third step is that blank buildings are placed at random along these smaller roads, they don't cluster yet but they should. The fourth and last step is probably the second most complicated one. RCI - Residential, Commercial, Industrial - which is probably a term some of you remember from SimCity. My game is not a strategy game, but for realism I will need these various facilities and thus thought it necessary to add them. The game will choose centers for each zone, and spread the zones into the blank buildings by proximity to these centers...the ones furthest from the centers will be considered "Light Residential", "Light Industrial", or "Light Commercial". Those are the lighter colors you see.

    Ladies and gentlemen, I present to you, in no certain order: Brightbourne, Whitemere, Lakegate, and Mossbridge. Four cities I generated in about one percent of the amount of time it took me to make this picture and write this post.

    <img src="">

    All of which you may or may not see in my game Crooked sooner or later, depending on how the generator treats you. Crooked is going to be a combination of Trilby: The Art of Theft, Zelda 2, and Spelunky - in that order. That is, assuming I ever finish the game.

    <img src="">

    Yes...I exaggerated the logo specifically to let you know it's pronounced with two syllables. But back to the subject at hand, procedural generation. A few things I've learned so far. I looked on the web for algorithms, and ended up not finding won't really, especially if you have specific needs. Even if you did find one, it's not going to translate into Construct very well, because Construct is almost conversational in implementation. You just have to imagine how you would draw it, or how it would be. I opened up paint, drew up some roads, and realized I was using 90 degree angles from random points, and that's where I began. Thinking of things literally in that way made it much easier to translate into Construct than trying to think of it mathematically or programmatically. Another thing - doing natural generation has to be a lot easier than doing man-made stuff I would imagine. Random terrain must be a snap compared to this. Anyway, if any of you have any questions, tips, or suggestions, please leave them.

    Edit: Posted in general because I don't have a cleanly commented *.cap to upload yet, and while I have plans on making one - this isn't a tutorial yet either.

  • Seems really cool and if it works well im very very interested and when you are ready to publish it please do it as freeware

  • HELL YES. I've been a huge advocate for procedural generation, because it is capable of absolutely incredible things, especially in 3D. Interesting city generation thing... I wonder how procedural terrain generation could work in Construct while actually looking nice?

  • I wonder how procedural terrain generation could work in Construct while actually looking nice?

    lol arsonide your thing doesn't look nice

    At this point it's pretty much purely an algorithm. He does plan on making each building/road/etc a tile (or 3D box as the case may be).

  • lol arsonide your thing doesn't look nice

    At this point it's pretty much purely an algorithm. He does plan on making each building/road/etc a tile (or 3D box as the case may be).

    The algorithm is the hard part, applying art to those little dots will be a snap.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Subscribe to Construct videos now

    - Whabam! A snap I say! Whipped this up before work specifically for deadeye.

    Wish I could keep working on it, but unfortunately Construct requires a running computer - and therefore electricity - and therefore money.

  • Looking pretty good so far, man

  • While a good start, you need curves in order to keep the world from being too boxy. I do procedural generation all the time (I work on cell phones) and the simplest way to add curves to your system is with partial circles.

    <img src="">

    You just need to generate a circle starting at point A and then at the opposite side, point B. The red portions of the circle are what you can erase or ignore, and by doing so you have a curved road.

    Might take a while to get right, but having curves will make the world that much more enjoyable.

  • Or one quarter of the circle for gentle turns. But how do you define a circle in a 2D array without it looking ugly? Especially if you're using low resolution arrays.

  • Don't actually draw the circle in the array, just the key points of it.

    I guess I don't know exactly how he has his system set up, maybe he would need a second system for curves, but the point is to just use the array for key points in the circle (NSEW).

    He is applying art to the array, so I would imagine he can work out a way to place the circles correctly.

    For example, he could make it really easy and just set a few sizes (like 4) and then just line the correct art up to the points of the curve.

  • Not sure about curves at the moment, Mipey's right, if only key points of a curve are stored in the array then I'll have the curve going over some things on the array - if the curve is stored in two points on both ends, with the curve in the center, then the generator might think those center squares are grass or something. I could do it old school like curves in those old Transport Tycoon games - where a curve is actually like a gigantic L shaped tetris piece on the array, but visually pleasing in the world. Even then though, buildings won't be able to come flush up against the road for instance. It's something to think about, but definitely a tricky situation.

    Right now deadeye has me concerned with sidewalks and street paint and all the gritty stuff involving getting those roads and intersections looking like roads and intersections instead of ... well ... sprites on an array.

  • Well I wish you luck, and encourage you to try curves at some point. Box worlds can only take you so far, and for a car game that distance is a bit shorter

  • More progress, looks much more professional. Threw in some props for Construct as well should anybody stumble across the movie while crawling through Youtube videos. Deadeye was telling me that some extra muscle around here would be good for the program.

    Subscribe to Construct videos now

    I'd actually done a rudimentary traffic model at the time this footage was taken, but I based it on the "grid" movement behavior, and I think bullet would be better. Grid is much easier to use, but it's kind of hard to get them to stay in their lanes when they are turning. I turned it off for the footage.

  • Wow. That is impressive. I do hope you'll write a tutorial someday.

  • i'm looking forward to your progress! please check your videos for the correct aspect ratio next time, so your video diary is less irritating to watch.

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