From a0ef84b0474219bedf603a293a2ee8d4fab32ec0 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Sat, 16 Oct 2021 22:04:31 -0400 Subject: Add Godot and Rust files --- klangfarbrs/src/lib.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 klangfarbrs/src/lib.rs (limited to 'klangfarbrs/src') diff --git a/klangfarbrs/src/lib.rs b/klangfarbrs/src/lib.rs new file mode 100644 index 0000000..4843910 --- /dev/null +++ b/klangfarbrs/src/lib.rs @@ -0,0 +1,29 @@ +use gdnative::prelude::*; + +/// The HelloWorld "class" +#[derive(NativeClass)] +#[inherit(Node)] +pub struct HelloWorld; + +#[methods] +impl HelloWorld { + fn new(_owner: &Node) -> Self { + HelloWorld + } + + #[export] + fn _ready(&self, _owner: &Node) { + // The `godot_print!` macro works like `println!` but prints to the Godot-editor + // output tab as well. + godot_print!("Hello, world!"); + } +} + +// Function that registers all exposed classes to Godot +fn init(handle: InitHandle) { + // Register the new `HelloWorld` type we just declared. + handle.add_class::(); +} + +// Macro that creates the entry-points of the dynamic library. +godot_init!(init); -- cgit v1.2.3