mirror of
https://github.com/godotengine/gdnative-demos.git
synced 2026-01-01 05:48:13 +03:00
Made this work with Godot 3.0 beta
This commit is contained in:
@@ -9,23 +9,13 @@
|
||||
[ext_resource path="res://Player Red/playerRed_up2.png" type="Texture" id=7]
|
||||
[ext_resource path="res://Player Red/playerRed_up3.png" type="Texture" id=8]
|
||||
|
||||
[sub_resource type="GDNativeLibrary" id=3]
|
||||
|
||||
platform/X11_32bit = ""
|
||||
platform/X11_64bit = "res://Script/bin/libkinematic_char.so"
|
||||
platform/Windows_32bit = ""
|
||||
platform/Windows_64bit = ""
|
||||
platform/OSX = ""
|
||||
platform/Android = ""
|
||||
platform/iOS = ""
|
||||
platform/WebAssembly = ""
|
||||
_sections_unfolded = [ "platform" ]
|
||||
[ext_resource path="res://Script/bin/libkinematic_char.gdnlib" type="GDNativeLibrary" id=9]
|
||||
|
||||
[sub_resource type="NativeScript" id=4]
|
||||
|
||||
resource_name = "GDPlayer"
|
||||
class_name = "GDPlayer"
|
||||
library = SubResource( 3 )
|
||||
library = ExtResource( 9 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
|
||||
|
||||
20
cpp/kinematic_character/README.md
Normal file
20
cpp/kinematic_character/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# GDNative example of a kinematic character
|
||||
|
||||
This is a demo showing how to use GDNative together with the cpp_bindings layer to implement a couple of new nodes.
|
||||
This demo was originally created by Ramesh Ravone.
|
||||
|
||||
Before compiling this module you must clone https://github.com/GodotNativeTools/godot_headers and https://github.com/GodotNativeTools/godot-cpp
|
||||
Note that both are git submodule in Scripts/src so you can initialise these with git submodule but at you'll likely use these for other projects as well I advise giving them their own location.
|
||||
|
||||
After both repositories have been downloaded you need to compile the cpp bindings, for this follow the instructions in the godot-cpp repository.
|
||||
|
||||
Note that if you are on the latest master of Godot it is possible godot_headers is outdated. Instead of using this repository you can also use <godot-source>/modules/gdnative/include
|
||||
Make sure that you compile both godot-cpp and this repository using the same headers.
|
||||
|
||||
Once you are then ready to compile this module simply cd into the Scripts subfolder and execute:
|
||||
scons platform=xyz
|
||||
where xyz is your platform (linux, window and osx are currently supported).
|
||||
|
||||
If you have installed godot_headers and/or godot-cpp in a different location you can use the swiches headers and cpp_bindings respectively. You can also set these paths using the environmental variables GODOT_HEADERS and CPP_BINDINGS, that is particularly useful if you have multiple projects.
|
||||
|
||||
Finally you can switch between release and debug builds by adding the switch target. This must line up with the setting you use for compiling godot-cpp.
|
||||
Binary file not shown.
@@ -1,14 +1,22 @@
|
||||
#!python
|
||||
import os
|
||||
|
||||
env = Environment()
|
||||
|
||||
# platform= makes it in line with Godots scons file, keeping p for backwards compatibility
|
||||
platform = ARGUMENTS.get("p", "linux")
|
||||
godot_headers_path = ARGUMENTS.get("headers", "godot_headers/")
|
||||
godot_bindings_path = ARGUMENTS.get("cpp_bindings", "cpp_bindings/")
|
||||
godot_src_path = ARGUMENTS.get("godotpath", "../../../../godot3-git/")
|
||||
platform = ARGUMENTS.get("platform", platform)
|
||||
|
||||
# This makes sure to keep the session environment variables on windows,
|
||||
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
||||
env = Environment()
|
||||
if platform == "windows":
|
||||
env = Environment(ENV = os.environ)
|
||||
|
||||
godot_headers_path = ARGUMENTS.get("headers", os.getenv("GODOT_HEADERS", "godot_headers"))
|
||||
godot_bindings_path = ARGUMENTS.get("cpp_bindings", os.getenv("CPP_BINDINGS", "cpp_bindings"))
|
||||
|
||||
# default to debug build, must be same setting as used for cpp_bindings
|
||||
target = ARGUMENTS.get("target", "debug")
|
||||
|
||||
godot_name = "godot." + ("x11" if platform == "linux" else platform) + ".tools.64"
|
||||
|
||||
if ARGUMENTS.get("use_llvm", "no") == "yes":
|
||||
env["CXX"] = "clang++"
|
||||
@@ -22,22 +30,21 @@ elif platform == "linux":
|
||||
env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\''])
|
||||
elif platform == "windows":
|
||||
# need to add detection of msvc vs mingw, this is for msvc...
|
||||
env.Append(CCFLAGS = ['/MD', '/WX', '/O2', '/EHsc', '/nologo'])
|
||||
env.Append(LINKFLAGS = ['/WX'])
|
||||
if target == "debug":
|
||||
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '/MDd'])
|
||||
else:
|
||||
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '/MD'])
|
||||
|
||||
def add_sources(sources, dir):
|
||||
for f in os.listdir(dir):
|
||||
if f.endswith(".cpp"):
|
||||
sources.append(dir + "/" + f)
|
||||
|
||||
env.Append(CPPPATH=[godot_headers_path, godot_bindings_path + 'include/', godot_bindings_path + 'include/core/', 'src' ])
|
||||
env.Append(CPPPATH=[godot_headers_path, godot_bindings_path + '/include/', godot_bindings_path + '/include/core/', 'src' ])
|
||||
|
||||
env.Append(LIBS=['godot_cpp_bindings'])
|
||||
env.Append(LIBPATH=[ godot_bindings_path + 'bin/' ])
|
||||
|
||||
if platform == "windows":
|
||||
env.Append(LIBS=[ godot_name ])
|
||||
env.Append(LIBPATH=[ godot_src_path + 'bin/' ])
|
||||
env.Append(LIBPATH=[ godot_bindings_path + '/bin/' ])
|
||||
|
||||
sources = []
|
||||
add_sources(sources, "src")
|
||||
|
||||
17
cpp/kinematic_character/Script/bin/libkinematic_char.gdnlib
Normal file
17
cpp/kinematic_character/Script/bin/libkinematic_char.gdnlib
Normal file
@@ -0,0 +1,17 @@
|
||||
[general]
|
||||
|
||||
singleton=false
|
||||
load_once=false
|
||||
symbol_prefix="godot_"
|
||||
|
||||
[entry]
|
||||
|
||||
X11.64="res://Script/bin/libkinematic_char.so"
|
||||
Windows.64="res://Script/bin/libkinematic_char.dll"
|
||||
OSX.64="res://Script/bin/libkinematic_char.dylib"
|
||||
|
||||
[dependencies]
|
||||
|
||||
X11.64=[]
|
||||
Windows.64=[]
|
||||
OSX.64=[]
|
||||
@@ -1,23 +0,0 @@
|
||||
[gd_resource type="GDNativeScript" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="GDNativeLibrary" id=1]
|
||||
|
||||
platform/unix = ""
|
||||
platform/x11 = "res://Script/lib/libgodot_char_control.so"
|
||||
platform/server = ""
|
||||
platform/android = ""
|
||||
platform/haiku = ""
|
||||
platform/mac = ""
|
||||
platform/ios = ""
|
||||
platform/osx = ""
|
||||
platform/html5 = ""
|
||||
platform/windows = ""
|
||||
platform/uwp = ""
|
||||
_sections_unfolded = [ "platform" ]
|
||||
|
||||
[resource]
|
||||
|
||||
resource_name = "GDPlayer"
|
||||
library = SubResource( 1 )
|
||||
script_name = "GDPlayer"
|
||||
|
||||
11
cpp/kinematic_character/Script/char_con.gdns
Normal file
11
cpp/kinematic_character/Script/char_con.gdns
Normal file
@@ -0,0 +1,11 @@
|
||||
[gd_resource type="GDNativeScript" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Script/bin/libkinematic_char.gdnlib" type="GDNativeLibrary" id=1]
|
||||
|
||||
[resource]
|
||||
|
||||
resource_name = "GDPlayer"
|
||||
class_name = "GDPlayer"
|
||||
library = ExtResource( 1 )
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
[gd_resource type="GDNativeScript" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="GDNativeLibrary" id=1]
|
||||
|
||||
platform/unix = ""
|
||||
platform/x11 = "res://Script/lib/libgodot_char_control.so"
|
||||
platform/server = ""
|
||||
platform/android = ""
|
||||
platform/haiku = ""
|
||||
platform/mac = ""
|
||||
platform/ios = ""
|
||||
platform/osx = ""
|
||||
platform/html5 = ""
|
||||
platform/windows = ""
|
||||
platform/uwp = ""
|
||||
_sections_unfolded = [ "platform" ]
|
||||
|
||||
[resource]
|
||||
|
||||
resource_name = "GDPlayer"
|
||||
library = SubResource( 1 )
|
||||
script_name = "ColWorld"
|
||||
|
||||
11
cpp/kinematic_character/Script/colworld.gdns
Normal file
11
cpp/kinematic_character/Script/colworld.gdns
Normal file
@@ -0,0 +1,11 @@
|
||||
[gd_resource type="GDNativeScript" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Script/bin/libkinematic_char.gdnlib" type="GDNativeLibrary" id=1]
|
||||
|
||||
[resource]
|
||||
|
||||
resource_name = "GDPlayer"
|
||||
class_name = "ColWorld"
|
||||
library = ExtResource( 1 )
|
||||
|
||||
|
||||
0
cpp/kinematic_character/Script/src/.gdignore
Normal file
0
cpp/kinematic_character/Script/src/.gdignore
Normal file
@@ -18,7 +18,6 @@
|
||||
#define PLAYER_H
|
||||
|
||||
#include <Godot.hpp>
|
||||
|
||||
#include <InputEvent.hpp>
|
||||
#include <RayCast2D.hpp>
|
||||
|
||||
|
||||
@@ -5,25 +5,13 @@
|
||||
[ext_resource path="res://Character.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://circle.png" type="Texture" id=4]
|
||||
[ext_resource path="res://long_obstacle.png" type="Texture" id=5]
|
||||
|
||||
[sub_resource type="GDNativeLibrary" id=1]
|
||||
|
||||
platform/X11_32bit = ""
|
||||
platform/X11_64bit = "res://Script/bin/libkinematic_char.so"
|
||||
platform/Windows_32bit = ""
|
||||
platform/Windows_64bit = ""
|
||||
platform/OSX = ""
|
||||
platform/Android = ""
|
||||
platform/iOS_32bit = ""
|
||||
platform/iOS_64bit = ""
|
||||
platform/WebAssembly = ""
|
||||
_sections_unfolded = [ "platform" ]
|
||||
[ext_resource path="res://Script/bin/libkinematic_char.gdnlib" type="GDNativeLibrary" id=6]
|
||||
|
||||
[sub_resource type="NativeScript" id=2]
|
||||
|
||||
resource_name = "ColWorld"
|
||||
class_name = "ColWorld"
|
||||
library = SubResource( 1 )
|
||||
library = ExtResource( 6 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ config_version=3
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Kinematic Character"
|
||||
run/main_scene="res://colworld.tscn"
|
||||
config/icon="res://icon.png"
|
||||
name="Kinematic Character"
|
||||
main_scene="res://colworld.tscn"
|
||||
icon="res://icon.png"
|
||||
|
||||
Reference in New Issue
Block a user