Plotting a road system for a large-scale racing game

0 favourites
  • 7 posts
From the Asset Store
Watercolor Fantasy Races Bundle includes over 2,100 images
  • As you can see here I've uploaded the map of a real-life Texas, USA city. My plan is to have a city-scale environment (although there will be a conservative adaption of this real-life map to game map...not all roads will find their way into the game for lots of reasons which I will not waste your time in detailing to have you read through).

    Since this map is obviously extremely analog rather than the likes old-school video game sprites that are reused throughout each course, there's going to be a lot of custom setting-up of roadways. There's going to be no easy way about this, whatever I decided to do. So I was hoping to get some input from experienced developers who are familiar with the less-than-cookie-cutter development of levels and environments.

    My initial idea was to create objects at intersections that serve "hubs" for where roads are drawn and connected to other roads and intersections. However, I foresee this will have its own inherent issues and will hinder me in drawing roads beyond flat black with no details (because sprites will overlap with little to no regard for how road lines come together at intersections and so on).

    The alternative is to manually place all the road pieces and draw unique road pieces where needed...which is probably going to be my main recourse for a map of this nature.

    Obviously, there are a ton of roads, so, as I mentioned, I won't be including every road of the real-city map in the game map. But for the roads I do adapt into the game, what do you suggest I do to make the process as streamlined or as easy as possible? Whether I have to manually place each road myself (including drawing custom pieces) or device a system that draws most of the road pieces at Start Of Layout?

    I'd be grateful for any and all suggestions. I only hope I am able to understand and follow it all - despite all I know now, I'm still learning a ton and am only all too away that I'm ignorant about a lot. This is definitely the biggest project I've attempted so far...

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • My take on this would be to store the image information in a tilemap (1x1, 2x2 etc. pixels depending on desired resolution), then go through the whole thing and do bitwise operations on each tile and determine what to put there (e.g, if a "white" tile has "white" neighbor tiles to east, west, south and north direction, this must be an intersection).

    You have to deal with roads that are not complete 90 degrees angles over longer distances though. Several interpolation algorithms can be applied here.

  • My take on this would be to store the image information in a tilemap...

    You have to deal with roads that are not complete 90 degrees angles over longer distances though. Several interpolation algorithms can be applied here.

    I want to say that I'm following your meaning with this suggestion - which, for the very little that I think I grasp, I think could work - but honestly, I'm at a loss as to just how you mean for this to play out. Might I trouble you to detail what you mean exactly? Dare I ask for some images or sketches to help me visualize what you mean?

  • Before settling on a way to tackle this I'd try to better define what I want to do. Go full hog at first and then whittle down features till it's more reasonable and doable.

    Will I want all the roads to be the same or would I like variations like driveways, multi-lane highways, country roads, etc...

    From the above I'd want to try to think up how I'd want the intersections and transitions between the roads to look. Probably make lots of diagrams as examples.

    Would you want different road heights? Bridges and tunnels?

    To define the roads you could just make up a bunch of building block images of road pieces. They don't have to be grid based but in practice it's hard to have them match up otherwise, although I'd imagine it's possible.

    For full analog with roads going every which way I'd go with generating the road graphics with code. The intersections would be trickier but then again I'm not really sure how I'd want them to look. Roughly off the top of my head a straight road would be a solid color rectangle with two fog lines on the side, and a dashed yellow line in the middle. Curved roads are just multiple straight roads, and intersections could be done by drawing a solid color polygon over the intersecting part. Again I'd need to figure out the different looks for intersections and maybe make it so you could choose form different styles.

    To define the roads I'd want to keep the tedium to a minimum. You could probably simplify defining roads to just drawing lines and have the intersections figured out with code. The constuct editor isn't suitable for defining a bunch of lines like that, so I'd either make an in game editor or utilize some vector drawing app and pick a save format that I can pull the lines from with minimal coding effort.

    For in game you'd want to be able to draw all that reasonably fast, and since you would usually be pretty low you'd only need to draw the roads with all their details around the player. You wouldn't want to have to check every road so you could just have large squares that roads are part of, and if the square is in view just draw all the roads in them.

    Anyways just some ideas. I'd do a lot of mini tests with the different aspects to see if they are achievable. I'd probably simplify things down a lot to make everything more doable in a reasonable amount of time.

  • R0J0hound - Thank you for your input. That seems to be a bit more feasible. An incredible mental challenge...but feasible.

    Taking into account what you've gone over...

    Road types: While I would love to have a game along the lines of Need For Speed: Most Wanted (my favorite full-city sandbox racing game) with all manner of city road types, I plan to keep the road types/widths uniform. I don't think there will be any real exceptions even when it comes to the awkward-angled intersections. For the game missions, there might be some unique side roads or "pit stop" areas, but nothing exotic or exceedingly out of the norm.

    Intersections: Probably the most challenging given the layout of the city. The trick will be how to merge two sides of the roads coming together when the road lines are considered. Alternatively, I could simply draw custom sprites for the intersections. It would be a lot...but far better than trying to work out a system to merge roads...especially ones coming in at angles.

    Road heights and bridges: My plan so far is to have 3 levels, minimum: Ground level, upper level (overpasses, "major" roadways that act kinda like shortcuts between districts), and underground. Alternatively, I was thinking about having the "ground level" have its own progressive elevations throughout the city...much like the real city this is based on. But initial efforts have proven this may not be as timely as I'd like as it would require a lot of manual editing. I'm probably going to resort to keeping the ground level completely flat and having the roads shift between specified elevation levels or just keep it at a strict "ground", "upper", and "underground" for simplicity...

    Analog roads: And that's where the trick comes in. The careful plotting of road pieces - many, many of them - that create the semblance of progressive turns and angles. Without drawing them out, the angles of the straight roads connecting will be obvious. That's fine. All of that you mentioned. Then I could connect them all by the custom-drawn intersections sprites.

    Drawing roads in-game: My plan does include road segments being constructed along the lengths of lines placed in the editor and then actually spawned when the player car is within range. I've also been trying to figure out if utilizing an Array contained with respective road pieces might help generate roads in-game when the player is nearby.

  • Hi, here are some further thoughts and experiments.

    Road types and intersections:

    It's probably simpler to use uniform width roads initially anyway. Here is one hack attempt to do the roads with edges and center dashed line. The dashed lines could be made to go to the center of intersections by using another object with this setup, although i realize that's not how intersections look. Any look can probably be achieved with some thought. doing the drawing with polygons could be a cleaner idea possibly.

    dropbox.com/s/kpdxx2xge14fztx/road_gen.capx

    Different levels would probably be easier with 3d polygons, but those don't really exist in construct. I see you did a layering+zelevation way of doing it in your other posts though.

    Also, by drawing roads in game, i meant it as an idea to make a dev tool in your game to make placing and designing roads easier for yourself. They could be used for the player to utilize later i suppose, but primarily it would be so you wouldn't have to do it all in construct's editor.

    Finally here are some tests about dealing with a large amount of roads. I wasn't going to design all that but i did find that i could get real road layouts with Open Street Map. It lets you export an osm file of the current view. It's just xml inside, and i could convert the relevant parts to something i could parse in construct easier.

    dropbox.com/s/rxus2szbpsfzlrv/loader_and_plot.capx

    That's clearly a lot of sprites to draw, so I scaled it up and did an initial first pass at splitting the map into grid chunks, and only drawing the chunk the player is on. Normally the transition would be seamless, but it was only a rough test. I wonder though if Construct's built in hashing would be acceptable enough.

    dropbox.com/s/bya1jhzdtkrrufo/loader_and_plot_gridhash.capx

    Anyways i thought those capx were fun to share. I do think i missed the mark in making something completely useful. Hopefully it's helpful or interesting.

  • Nice work R0J0hound!

    Seems like your fingers were itchier than mine :D

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