Skip to content

Commit

Permalink
add a custom godot node
Browse files Browse the repository at this point in the history
  • Loading branch information
trevyn committed Sep 14, 2024
1 parent 78b1ead commit 20fffe8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Godottest/deckbuilder.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[configuration]
entry_symbol = "gdext_rust_init"
compatibility_minimum = 4.3
reloadable = true

[libraries]
linux.debug.x86_64 = "res://../deckbuilder/target/debug/libdeckbuilder.so"
linux.release.x86_64 = "res://../deckbuilder/target/release/libdeckbuilder.so"
windows.debug.x86_64 = "res://../deckbuilder/target/debug/deckbuilder.dll"
windows.release.x86_64 = "res://../deckbuilder/target/release/deckbuilder.dll"
macos.debug = "res://../deckbuilder/target/debug/libdeckbuilder.dylib"
macos.release = "res://../deckbuilder/target/release/libdeckbuilder.dylib"
macos.debug.arm64 = "res://../deckbuilder/target/debug/libdeckbuilder.dylib"
macos.release.arm64 = "res://../deckbuilder/target/release/libdeckbuilder.dylib"
2 changes: 1 addition & 1 deletion Godottest/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config_version=5

config/name="videoproject"
run/main_scene="res://res/node_2d.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
config/features=PackedStringArray("4.4", "Forward Plus")
boot_splash/bg_color=Color(0, 0, 0, 1)
boot_splash/show_image=false

Expand Down
34 changes: 34 additions & 0 deletions deckbuilder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
use godot::prelude::*;

// #![allow(unused)]
fn main() {
struct MyExtension;

#[gdextension]
unsafe impl ExtensionLibrary for MyExtension {}
}

use godot::classes::{INode, Node};

#[derive(GodotClass)]
#[class(base=Node)]
struct MyPlayer {
speed: f64,
angular_speed: f64,

base: Base<Node>,
}

#[godot_api]
impl INode for MyPlayer {
fn init(base: Base<Node>) -> Self {
godot_print!("Hello, worldd!"); // Prints to the Godot console

Self {
speed: 400.0,
angular_speed: std::f64::consts::PI,
base,
}
}
}

pub mod tutorial;

mod logger;
Expand Down

0 comments on commit 20fffe8

Please sign in to comment.