diff --git a/c/README.md b/c/README.md index 010485a..1adbbd1 100644 --- a/c/README.md +++ b/c/README.md @@ -2,6 +2,8 @@ These demos show how to use the GDNative C bindings. +Language: [GDNative C](https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/index.html) + Dependencies: * You need [Godot headers](https://github.com/godotengine/godot-headers), this is now a Git submodule of this repo. diff --git a/c/glfw/README.md b/c/glfw/README.md index 9052ab2..e9e1fad 100644 --- a/c/glfw/README.md +++ b/c/glfw/README.md @@ -3,6 +3,10 @@ This is a small example using C to create a GDNative script that exposes a very small part of the GLFW API. +Language: [GDNative C](https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/index.html) + +Renderer: GLES 2 + Dependencies: * You need [Godot headers](https://github.com/godotengine/godot-headers), this is now a Git submodule of this repo. @@ -20,7 +24,6 @@ scons platform=PLATFORM Where PLATFORM is: `windows`, `linuxbsd`, or `macos`. - ## Manually compiling ### Linux diff --git a/c/instance_binding/README.md b/c/instance_binding/README.md index d43581a..8eee5e4 100644 --- a/c/instance_binding/README.md +++ b/c/instance_binding/README.md @@ -1,5 +1,9 @@ # Instance binding demo using C +Language: [GDNative C](https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/index.html) + +Renderer: GLES 2 + Dependencies: * You need [Godot headers](https://github.com/godotengine/godot-headers), this is now a Git submodule of this repo. @@ -14,7 +18,6 @@ scons platform=PLATFORM Where PLATFORM is: `windows`, `linuxbsd`, or `macos`. - ## Manually compiling ### Linux diff --git a/c/simple/README.md b/c/simple/README.md index 5d2120b..b983e97 100644 --- a/c/simple/README.md +++ b/c/simple/README.md @@ -3,6 +3,10 @@ This is a small example using C to create a GDNative script that just showcases some very simple bare bones calls. +Language: [GDNative C](https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/index.html) + +Renderer: GLES 2 + Dependencies: * You need [Godot headers](https://github.com/godotengine/godot-headers), this is now a Git submodule of this repo. @@ -17,7 +21,6 @@ scons platform=PLATFORM Where PLATFORM is: `windows`, `linuxbsd`, or `macos`. - ## Manually compiling ### Linux diff --git a/cpp/README.md b/cpp/README.md index ed23228..59f9bc3 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -2,6 +2,8 @@ These demos show how to use the GDNative C++ bindings. +Language: [GDNative C++](https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/index.html) + Dependencies: * You need [godot-cpp](https://github.com/godotengine/godot-cpp), this is now a Git submodule of this repo. diff --git a/cpp/dodge_the_creeps/README.md b/cpp/dodge_the_creeps/README.md index 41dfd6f..54bc3b6 100644 --- a/cpp/dodge_the_creeps/README.md +++ b/cpp/dodge_the_creeps/README.md @@ -8,7 +8,7 @@ This is a finished version of the game featured in the tutorial in the documentation. For more details, consider following the tutorial in the documentation. -Language: GDScript +Language: [GDNative C++](https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/index.html) Renderer: GLES 3 (particles are not available in GLES 2) @@ -26,7 +26,7 @@ scons platform=PLATFORM Where PLATFORM is: `windows`, `linux`, or `osx`. -This creates the file `libsimple` in the respective +This creates the file `libdodgethecreeps` in the respective subfolders in the `project/gdnative` directory. Dependencies: diff --git a/cpp/dodge_the_creeps/godot-cpp b/cpp/dodge_the_creeps/godot-cpp new file mode 160000 index 0000000..e08ecdc --- /dev/null +++ b/cpp/dodge_the_creeps/godot-cpp @@ -0,0 +1 @@ +Subproject commit e08ecdc28c5409cb5366027227e996c342dcee93 diff --git a/cpp/dodge_the_creeps/src/player.cpp b/cpp/dodge_the_creeps/src/player.cpp index fb6ab0c..084cf1d 100644 --- a/cpp/dodge_the_creeps/src/player.cpp +++ b/cpp/dodge_the_creeps/src/player.cpp @@ -1,20 +1,18 @@ #include "player.hpp" -#include - void Player::_ready() { _animated_sprite = get_node("AnimatedSprite"); _collision_shape = get_node("CollisionShape2D"); + _input = godot::Input::get_singleton(); _screen_size = get_viewport_rect().size; hide(); } void Player::_process(const double p_delta) { - godot::Input *input = godot::Input::get_singleton(); godot::Vector2 velocity(0, 0); - velocity.x = input->get_action_strength("move_right") - input->get_action_strength("move_left"); - velocity.y = input->get_action_strength("move_down") - input->get_action_strength("move_up"); + velocity.x = _input->get_action_strength("move_right") - _input->get_action_strength("move_left"); + velocity.y = _input->get_action_strength("move_down") - _input->get_action_strength("move_up"); if (velocity.length() > 0) { velocity = velocity.normalized() * speed; diff --git a/cpp/dodge_the_creeps/src/player.hpp b/cpp/dodge_the_creeps/src/player.hpp index 5baf68c..b046c75 100644 --- a/cpp/dodge_the_creeps/src/player.hpp +++ b/cpp/dodge_the_creeps/src/player.hpp @@ -5,12 +5,14 @@ #include #include #include +#include class Player : public godot::Area2D { GODOT_CLASS(Player, godot::Area2D) godot::AnimatedSprite *_animated_sprite; godot::CollisionShape2D *_collision_shape; + godot::Input *_input; godot::Vector2 _screen_size; // Size of the game window. public: diff --git a/cpp/pong/README.md b/cpp/pong/README.md index c409c10..bd97bfa 100644 --- a/cpp/pong/README.md +++ b/cpp/pong/README.md @@ -4,7 +4,7 @@ A simple Pong game, made with GDNative C++. This demo shows best practices for game development in Godot, including [signals](https://docs.godotengine.org/en/latest/getting_started/step_by_step/signals.html). -Language: C++ +Language: [GDNative C++](https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/index.html) Renderer: GLES 2 @@ -24,7 +24,7 @@ scons platform=PLATFORM Where PLATFORM is: `windows`, `linux`, or `osx`. -This creates the file `libsimple` in the respective +This creates the file `libpong` in the respective subfolders in the `project/gdnative` directory. Dependencies: diff --git a/cpp/pong/godot-cpp b/cpp/pong/godot-cpp new file mode 160000 index 0000000..e08ecdc --- /dev/null +++ b/cpp/pong/godot-cpp @@ -0,0 +1 @@ +Subproject commit e08ecdc28c5409cb5366027227e996c342dcee93 diff --git a/cpp/simple/README.md b/cpp/simple/README.md index b73c85c..fa7d830 100644 --- a/cpp/simple/README.md +++ b/cpp/simple/README.md @@ -3,7 +3,7 @@ This is a small example using C++ to create a GDNative script that just showcases some very simple bare bones calls. -Language: C++ +Language: [GDNative C++](https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/index.html) Renderer: GLES 2 diff --git a/cpp/simple/godot-cpp b/cpp/simple/godot-cpp new file mode 160000 index 0000000..e08ecdc --- /dev/null +++ b/cpp/simple/godot-cpp @@ -0,0 +1 @@ +Subproject commit e08ecdc28c5409cb5366027227e996c342dcee93