Bitflinger Games docs

A worked example

Tall Meadow is a two-file game built on Starter World: the meadow at dusk, a higher jump, and a tower of steps with a coin on top. Its files are in the games repo under docs/examples/tall-meadow/, and tools/check.sh runs it every time, so this page can't drift from what works.

The manifest

variation.json names the parent, seals its own rule and describes what it adds.

{
  "name": "Tall Meadow",
  "version": "1.0.0",
  "summary": "The meadow at dusk, a higher jump, and a tower with a coin on top.",
  "added": "a tower, dusk",
  "creator": "Bitflinger",
  "parent": "starter-world",
  "entry": "layer.gd",
  "seal": ["rules.tower.steps"]
}

The script

layer.gd runs once when the layer loads. It includes one change that is refused, to show what that looks like.

extends Node

const Kit := preload("res://layers/starter-world/kit.gd")


func _ready() -> void:
	# Open rules of the parent: these take effect.
	Variations.set_rule("sky.time", 19.0)
	Variations.set_rule("player.jump_height", 3.4)
	# Sealed by the parent: this returns false and gravity stays 24.
	Variations.set_rule("world.gravity", 6.0)
	# A rule of your own. The manifest seals it for games built on this one.
	Variations.set_rule("tower.steps", 12)
	# A zone of your own, built beside the parent's meadow.
	Variations.register_zone("tower", _build)
	Variations.event.connect(_on_event)


func _on_event(event_name: String, _payload: Dictionary) -> void:
	if event_name == "world.ready":
		Variations.emit_event("hud.message", {"text": "Climb the tower"})


func _build() -> Node3D:
	var zone := Node3D.new()
	var steps: int = Variations.rule("tower.steps", 12)
	var at := Vector3.ZERO
	for i in steps:
		at = Vector3(12 + cos(i * 0.8) * 4.0, 0.8 + i * 1.2, sin(i * 0.8) * 4.0)
		zone.add_child(Kit.box(Vector3(2.4, 0.5, 2.4), Jewel.AMETHYST, at))
	var coin := Variations.make_item("coin")
	coin.position = at + Vector3(0, 1.4, 0)
	zone.add_child(coin)
	return zone

What happens

The game's report shows every outcome: the two open rules changed, the new rule and zone are there, and gravity is untouched.

"rules": {"sky.time": 19.0, "player.jump_height": 3.4, "world.gravity": 24.0, "tower.steps": 12, ...}
"zones": ["meadow", "tower"]
"denied": ["tall-meadow may not change rules.world.gravity"]

On screen the coin counter reads 0 of 11, one more than Starter World's 10, and "Climb the tower" shows at the start.