Zirrrus

[Dev Log] Walking an unfamiliar city alone

Recommended Posts

After trying my hand at a heavily authored "experience" last time, it's time to go back to what I like and know-ish: procedural generation.

 

My plan is to have an infinite city where you walk along streets with buildings on both sides and occasional landmarks.

 

I've done a little bit of prototyping and have a basic system for generating a curved road between two points with blocks of varying size as building placeholders.

 

progress_000.thumb.png.0d49568eaf808c4dbccbaea14aff181a.png

(and there already is a bug...)

 

The big problem right now is how to generate points with connections between them that obey certain rules so the streets don't cross/intersect in weird ways. I've implemented Poisson disc sampling for picking points that are not too close together and now the best step seems to be using Delaunay triangulation to turn that into a net-type thing. Implementing a weird mathematical procedure seems pretty daunting.

 

Further plans/challenges:

  • generate a city-like map of points and lines
  • properly connect streets at intersection points
  • generate building facades out of parts
  • add special features like open squares etc
  • cull/hide streets you can't see for performance
  • dynamically delete old and generate new sections of the city
  • cutting scope for time reasons

 

Share this post


Link to post
Share on other sites

This sounds rad, and the road generation looks cool so far. Good luck with implementing a weird mathematical procedure! I thought about doing that for the city generation in my procedural racing thing, but since I'd already written the code to generate the roads, it would have been more difficult to fit something around that than to just write my own thing that wasn't quite as good but did the job. Plus it was daunting!

Share this post


Link to post
Share on other sites

Very excited to see how this will develop. I have very little technical understanding about the subject but I love wandering around vast proc.gen landscapes. Also the city setting is interesting as usually in proc.gen games like in Minecraft/No Man's Sky you are hanging around in the wilderness.

Share this post


Link to post
Share on other sites

I spent most of the day writing and then debugging the triangulation. It's still wrong and broken but until half an hour ago was doing just nothing.

Good thing it doesn't have to be very efficient because I implemented(well, tried to) the Bowyer-Watson algorithm, which is very naive and pretty much brute-forces the triangulation by just going over everything over and over. Hopefully I can finish this up tomorrow because it's a fairly small part of the project.

vKamoye.png

Share this post


Link to post
Share on other sites

Today I managed to finally solve the remaining issues with the script. First I spent some time writing myself a library for 2D geometry functions and such though. That was fun, if not necessary for advancing the game.

 

Now I can generate a point set and properly triangulate it, like this:

FBv0ihb.png

The plan is to maybe randomly remove some edges and then create walkable streets along the lines in the diagram(adding some curviness). So every vertex in the diagram is an intersection. That will most likely lead to many Flatiron-type buildings, but I'm not going for realism.

Another way would be to generate the buildings offset inside the triangles, that would automatically create the streets in between. Adding curves to them would be difficult though...but should be overall a lot easier.

I'm still figuring out what data structures would be good to keep track of everything, once I have that squared away I can start generating the streets along the edges. The next challenge after that is properly connecting streets at intersections.

And then comes some art, making a variety of doors, windows and other features for the buildings.

Share this post


Link to post
Share on other sites

Well, the Flatiron building seems more realistic to me than all cube buildings.

 

Excited to wander these streets!

Share this post


Link to post
Share on other sites

The version where building get created inside the triangles is done. For now they are just made up of planes. And triangular. I've looked into merging them together, but polygons are a lot more difficult to handle since they can have all sorts of weird shapes. Maybe tomorrow.

B0Jv9h5.png

Then I created a simple FPS controller and went in there...

N3XiLa9.png

 

Because of the strange angles the city has a rather alien feel to it at the moment. But I'm happy with the result so far.

Share this post


Link to post
Share on other sites

Got polygons working...mostly.

rwS2N1t.png

Insetting works most of the time. But when forming clusters of triangles and then merging them into polygons it occasionally fails. Especially the part where it tries to "walk along" the edges of the polygon to make sure it actually is a closed shape. Well, progress is slow but maybe I'll crack that nut tomorrow.

Share this post


Link to post
Share on other sites

Ooooh, nice! When I saw this as one of the recomendations I was thinking it could make for a cool Bernband-alike. This is kinda different, but very neat. Looking forward to seeing how the proc gen turns out.

Share this post


Link to post
Share on other sites

Polygons were mistakenly identifying themselves as their neighbors, causing a whole bunch of issues. Merging triangles works now, only issue I'm aware right now is edges being offset in the wrong direction. That happens because edges use their polygon's center to determine the direction for the offset. While it's not optimal it actually causes interesting features like cul-de-sacs, so it'll stay this way for now.

4sd4OCJ.png

Tomorrow I want to get some beveling on on the very pointy bits of the polygons, and then instantiate placeholder doors and windows on the buildings.

After that it's art, art, art. And maybe I'll add some gameplay?

Share this post


Link to post
Share on other sites

There is some sorcery at work here and the results are cray good. I'm curious about your level generation overall. Once you generate an area is it saved off somewhere so it looks the same when you return, or is it generated and then dumped? I can't tell which one would be easier to implement.

Share this post


Link to post
Share on other sites

Chamfering corners was a lot more tricky than I had though, but it works now:

hTVcPEu.png

 

And I made it generate windows(plus one door for every face of a building):

DmGJpzS.png

The weird blocks are placeholder decorative items, and the self-intersecting buildings are absolutely normal, if a bit avant-garde.

 

Problem is: I don't really feel like working on this anymore. The most interesting challenges are solved, apart from dynamically generating new parts of the city - which seems like it'll be a pain.

It's hot outside, I'm lazy and have very low energy. I'll try to get it to a "playable" state and upload it.

It was really fun working on this though, maybe it's just my mood atm. Thank you for the encouragement, everyone! :)

Share this post


Link to post
Share on other sites

Yeah this is just straight up wizardry. Procedural stuff blows my mind. Also chamfering is the best verb ever. I know you've said you'll just make this walkable and dump it, but I think it's a great achievement already, so well done!

Share this post


Link to post
Share on other sites

Impressive. Though when I hearing "walking an unfamiliar city alone" I (wrongly?) think of it as a calming experience. And this looks like a multicolored impossible maze which would stress anyone out. Seems like you could start this like "a calming walk. Doesn't that sound nice?" then move into "wrong! This is actually a hell you are trapped in!"

 

Fun stuff! Those buildings look cool.

Share this post


Link to post
Share on other sites

I've come to a decision: I won't submit my game to the jam.

It's neither fun, nor interesting, nor bad in a funny way. It's just plain boring, infinite bowls of oatmeal.

 

The tool which generates the stuff is pretty neat, and I'm happy with what I created there. But that then gets turned into something pretty lame and not anywhere near interesting enough to spend a few minutes with. With a bunch of decorations and better(and more noticeable) variation, as well as a goal, it might be okay, but I have neither the time nor drive to make those adjustments.

Before the next jam I need to figure out what I'm good at and what like to make. I'm noticing a strong trend towards failure by lack of motivation/momentum in my game projects and that I start losing interest as soon as the basic systems and data structures are done and I have to work on gameplay and content.

 

If you want to check it out regardless visit: https://zirrrus.itch.io/wauca

The password is wj9

Share this post


Link to post
Share on other sites

Hey not bad! The procedural generation is indeed impressive, and lightning fast!

 

If you're still updating it, here's some simple improvements I'd like to see(tho I'm sure these are already on your to-do list):

-Cursor.visible = false;

-Sun (directional light with realtime shadows)

-Fog(I usually dont like it, but in this case it could really add to the mystery of exploring these unknown streets)

-bigger play area.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now