Godot Integration
This guide integrates the Rust engine with Godot 4 via GDExtension using godot-rust.
Build the extension
make godot-build
Artifacts:
- Linux:
target/release/libtiletangle_godot.so - macOS:
target/release/libtiletangle_godot.dylib - Windows:
target/release/tiletangle_godot.dll
Project setup
- Use the example:
bindings/godot/examples/(containsproject.godot). - Copy the built library to
examples/godot/bin/<platform>/. - Edit
examples/godot/tiletangle_godot.gdextensionto point to your library. - Open the project and run
scenes/Main.tscn. - The extension registers a
WordEngineclass.
3D Scene (layers)
- Open
scenes/Main3D.tscnfrom the example project. - Script
scripts/Board3D.gdinitializes a 3D layout (type: "3d") and renders stacked layers. - Symbols are drawn as
Label3Dnodes above each cell. AdjustW/H/Din the script for different sizes.
API
WordEngine.new_game(config_json: String, players: int) -> boolWordEngine.play_move(placements_json: String) -> String(empty on error)WordEngine.get_board_json() -> StringWordEngine.set_free_word_mode(on: bool)
Toggle rules mid-session
- In the 2D example (
scripts/Board.gd), a top bar button toggles free-word mode by callingeng.set_free_word_mode(...).
GDScript example
var eng := WordEngine.new()
var ok := eng.new_game(CONFIG_JSON, 2)
if not ok:
push_error("Failed to init engine")
return
var score_json := eng.play_move('[{"x":7,"y":7,"kind_id":"A"}]')
print("Score:", score_json)
print("Board:", eng.get_board_json())
Notes
- The engine uses a JSON configuration. See the Classic demo and the Playground’s Snapshot tab for working
examples you can copy, or check
bindings/godot/examples/for sample configs used by the integration. - Example project paths:
bindings/godot/examples/scenes/Main.tscnbindings/godot/examples/scripts/Board.gdbindings/godot/examples/scripts/TestSmoke.gd