logo

Babylon.js Market

By Lawrence

5 minutes

A poker table needs two things before any card is dealt. It needs chips, and it needs a way to track whose turn it is. So we start there. PokerBetting handles both jobs. It keeps track of the chips, and it is the state machine that moves around the table and stops on you. The rest of the game is built on top of it.

Stacks of gold and clay poker chips around an emerald felt table with a growing central pot, one seat lit by a bright moving spotlight cursor to show whose turn it is while the others sit in shadow, faint glowing bet amounts hovering over each stack, warm gold and crimson accents on near-black, high-stakes and cinematic.

How to pick the build order

This game is made of fourteen components. We don't pick the build order by feel. Each component lists two things in its meta.json file. It lists the components it depends on. It also lists the events it emits and listens for. We sort by those two things:

  • A component comes after everything in its dependencies. It also comes after every component whose events it listens for.
  • So a component with no dependencies that emits events others wait on comes early.
  • The director depends on all of them and connects every event. So it comes last.

When you run that sort, PokerBetting comes first among the game pieces. It has zero dependencies. It never imports the deck, the cards, or an opponent. But it emits the turn, action, and chip events. The HUD, the keyboard, the pacer, and all three AIs listen for those events. So you build the thing everyone needs first. Then you build the things that depend on it. You can use this same sort on any library game to find its build order.

There is one exception at the end of this lesson. The HUD is a view with no dependencies. We add it early so you can watch the money move.

A build-order graph. Left column: components with no dependencies, built first, with PokerBetting highlighted at the top. Middle column: components that depend on the roots (CardFan, the PokerAI personalities, PokerTableCards), arrows pointing back to what they need. Right: PokerTableDirector, which depends on everyone, built last. A dashed edge shows PokerBetting's turn and chip events feeding the AI, pacer, HUD, input, and director.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search