Bridge Generator

Add to
My games
Add to
Wishlist
Save to
Collection
No reviews
Exceptional
Meh
Skip

About

Part of my ongoing procedural generation adventure is devising a way to connect arbitrary points in space at varying angles using a series of adjustable prefabricated segments. This can provide the important ability for a level generator to create cycles or closed paths that allow a player to return to a previous area via a different route, and it can enable chunks in my 3D chunk system to connect their interior geometry with the "doors" on their borders. Both of these concepts are or will soon be covered on my blog in more detail.

The gist of the algorithm:
1. Verify that the line connecting the end points and the rays defined by their facing directions can form a triangle; otherwise it is (probably) impossible to form a bridge connecting them without having to curve back and forth or more than 180 degrees.
2. Calculate (via multiple steps of trigonometry) where to insert a new corner that forms an isosceles triangle centered around the intersection of the two rays. The symmetry of the isosceles triangle is important to ensure that the curved segments can align with each other as well as both of the end points.
3. Instantiate curved segments and adjust their curvature until the angle between the end points is eliminated, and position these using the corners of the isosceles triangle so that they align precisely.
4. Fill the gaps between the two sets of curved segments with straight segments, using adjustable straight segments at the ends as needed to achieve a precise fit.

WASD or arrow keys to move a tower
Q and E to rotate a tower
M to switch control between towers
B to generate a bridge (and delete any existing one)
If a bridge does not appear, try adjusting the towers and make sure they point vaguely toward one another.

Platforms
Release date
Developer
problemecium
Age rating
Not rated

System requirements for Web

Read more...
Bridge Generator screenshot, image №2756866 - RAWG
Edit the game info
Last Modified: Mar 15, 2021

Where to buy

itch.io