Inspiration

We played too much Factorio and thought, "How hard can it be to write a conveyor belt engine from scratch in C++?" Spoiler: It involves significantly more linear algebra than we anticipated.

What it does

It’s a conveyor belt engine built from the ground up. You can drag your mouse to paint conveyor belts, and the game automatically calculates "Manhattan paths" (nice L-shapes) to connect your start and end points. It handles item collision (so things don't merge into a singularity), dynamic corner snapping, and terrain generation.

How we built it

We used C++ and TXLib. We built a custom grid system where every tile is aware of its neighbors. The "physics" is a custom implementation of a linked list where entities traverse segments, handle hand-offs, and interpolate their positions for smooth rendering.

Challenges we ran into

  • The Teleporting Bug: For a long time, items would hit a corner and instantly warp to the next tile. We had to implement geometric snapping and interpolation to make them curve smoothly.
  • Collision Logic: Initially, items would just stack on top of each other. We had to write a logic system where items politely wait for a gap before entering a belt.
  • Coordinate Systems: Mapping screen pixels (Top-Left 0,0) to OpenGL (Bottom-Left 0,0) to our Grid (Who knows anymore) caused a lot of headaches and backwards conveyors.

Accomplishments that we're proud of

  • The Drag-to-Build system feels buttery smooth and shows a live "ghost" preview.
  • The Auto-Snapping: If you build a belt sideways into another one, it dynamically morphs the existing belt into a corner. It feels magical.
  • It runs efficiently without a heavy game engine.

What we learned

  • push_front vs push_back makes a catastrophic difference in physics simulations.
  • Visualizing your math with debug lines is the only way to stay sane.
  • Building a grid system from scratch gives you a newfound respect for game engine developers.

What's next for OpenGBelts

  • Implementing splitters and mergers (the final boss of logistics).
  • Adding actual machines to mine the resources.
  • Refining the art so coal doesn't just look like a darker rock.

Built With

Share this project:

Updates