Gameplay Flow
The sample is built around a few shared resources. UI, gameplay logic, audio, and scene transitions all react to the same MEDS variables and events.
High-level flow
- The menu reads and edits shared MEDS resources.
- The robot and other listeners react to those resources.
- Pressing
Take Damageraises a shared MEDS event. - The damage event reduces the shared health variable.
- UI, audio, and scene logic all update from that same health resource.
Menu flow
The menu scene at samples/prefabs/menu.tscn is the main control surface for the sample.
It uses these bindings:
variable-driven-label.gdto display variable values in labelsbool-driven-checkbox.gdto editrobot-visibility.tresvariable-driven-slider.gdto editrobot-rotation.trescolor-driven-color-picker.gdto editdamage-color.tresvariable-driven-progress-bar.gdto displayrobot-health.tres
This means the UI does not need custom code for each control. It simply points each binding at the right MEDS resource.
Damage flow
The Take Damage button triggers the MEDS event samples/events/take-damage.tres.
The flow is:
- The button calls
raise_event()throughsamples/scripts/raise-event.gd. take-damage.tresemits itsevent_raised()signal.samples/scripts/robot.gdlistens to that event.- The robot subtracts
damage-amount.tresfromrobot-health.tres.
This is the core MEDS pattern in the sample: a resource event triggers gameplay, and a shared resource variable stores the result.
Health-driven reactions
Several systems react to robot-health.tres at the same time:
- the progress bar updates through
variable-driven-progress-bar.gd samples/scripts/heartbeat-controller.gdchanges audio volume and pitch based on the health rangesamples/scripts/scene-manager.gdswitches to the game-over scene when health reaches zero
This is useful because the sample does not need one big controller script to keep these systems in sync.
Variable-driven visuals
The sample also demonstrates direct variable-to-scene bindings outside the menu UI:
samples/scripts/bind-bool-var-to-visibility.gdappliesrobot-visibility.tresto a node'svisiblestatesamples/scripts/bind-float-var-to-rotation.gdappliesrobot-rotation.tresto a 3D node rotationsamples/scripts/bind-color-var-to-mat-albedo.gdappliesdamage-color.tresto a material color
These scripts are intentionally small. They show how MEDS resources can drive runtime behavior without introducing heavy coupling.
Scene transition flow
When robot-health.tres becomes 0 or lower:
samples/scripts/scene-manager.gdreceives the updated value.- The scene manager loads
samples/game-over.tscn. samples/scripts/game-over-manager.gdlets the player retry and return to the main sample scene.
Why this sample matters
This sample is small, but it covers the main MEDS ideas in one place:
- resources hold shared state
- events broadcast intent
- bindings connect resources to UI
- multiple systems can react to the same resource independently
- debugging is easier because the data lives in explicit resources instead of hidden node references