Merge pull request #54 from aaronfranke/outdated

Delete outdated C++ demos and improve outdated README files
This commit is contained in:
Aaron Franke
2021-07-10 00:17:31 -07:00
committed by GitHub
76 changed files with 94 additions and 2093 deletions

View File

@@ -11,7 +11,7 @@ For non-GDNative demos (GDScript, VisualScript, and C#), please see the
## Godot versions
The [`master`](https://github.com/godotengine/gdnative-demos) branch
is compatible with the latest stable Godot version (currently 3.2).
is compatible with the latest stable Godot version (currently 3.3).
Older Godot versions are not supported by this repo.
## Useful links

21
c/README.md Normal file
View File

@@ -0,0 +1,21 @@
# C demos
These demos show how to use the GDNative C bindings.
Dependencies:
* You need [Godot headers](https://github.com/godotengine/godot-headers),
this is now a Git submodule of this repo.
* `clang`, `gcc`, or any decent C compiler that's C11 compatible.
## Compiling
For each of the C demos, you can use SCons to compile the library:
```
scons platform=PLATFORM
```
Where PLATFORM is: `windows`, `linuxbsd`, or `macos`.
This creates the file `libsimple` in the respective
subfolders in the `project/gdnative` directory.

View File

@@ -4,9 +4,9 @@ This is a small example using C to create a GDNative script that
exposes a very small part of the GLFW API.
Dependencies:
* You need [Godot headers](https://github.com/godotengine/godot_headers),
this is now a submodule of this repo.
* `clang`, `gcc`, or any decent C compiler that's C11 or C99 compatible.
* You need [Godot headers](https://github.com/godotengine/godot-headers),
this is now a Git submodule of this repo.
* `clang`, `gcc`, or any decent C compiler that's C11 compatible.
* You need to have GLFW and its headers installed.
## Compile with SCons (cross platform)
@@ -16,7 +16,7 @@ You can use SCons to compile the library if you have it installed:
scons platform=PLATFORM
```
Where platform is: windows, linuxbsd, or macos
Where PLATFORM is: `windows`, `linuxbsd`, or `macos`.
## Manually compiling

View File

@@ -1,9 +1,9 @@
# Instance binding demo using C
Dependencies:
* You need [Godot headers](https://github.com/godotengine/godot_headers),
this is now a submodule of this repo.
* `clang`, `gcc`, or any decent C compiler that's C11 or C99 compatible.
* You need [Godot headers](https://github.com/godotengine/godot-headers),
this is now a Git submodule of this repo.
* `clang`, `gcc`, or any decent C compiler that's C11 compatible.
## Compile with SCons (cross platform)
You can use SCons to compile the library if you have it installed:
@@ -12,7 +12,7 @@ You can use SCons to compile the library if you have it installed:
scons platform=PLATFORM
```
Where platform is: windows, linuxbsd, or macos
Where PLATFORM is: `windows`, `linuxbsd`, or `macos`.
## Manually compiling

View File

@@ -4,9 +4,9 @@ This is a small example using C to create a GDNative script
that just showcases some very simple bare bones calls.
Dependencies:
* You need [Godot headers](https://github.com/godotengine/godot_headers),
this is now a submodule of this repo.
* `clang`, `gcc`, or any decent C compiler that's C11 or C99 compatible.
* You need [Godot headers](https://github.com/godotengine/godot-headers),
this is now a Git submodule of this repo.
* `clang`, `gcc`, or any decent C compiler that's C11 compatible.
## Compile with SCons (cross platform)
You can use SCons to compile the library if you have it installed:
@@ -15,7 +15,7 @@ You can use SCons to compile the library if you have it installed:
scons platform=PLATFORM
```
Where platform is: windows, linuxbsd, or macos
Where PLATFORM is: `windows`, `linuxbsd`, or `macos`.
## Manually compiling

View File

@@ -1,44 +1,21 @@
## C++
# C++ demos
### Initial setup
These demos show how to use the GDNative C++ bindings.
You need to clone the GDNative C++ bindings in the root of this project:
Dependencies:
* You need [godot-cpp](https://github.com/godotengine/godot-cpp),
this is now a Git submodule of this repo.
* `clang`, `gcc`, or any decent C++ compiler that's C++14 compatible.
## Compiling
For each of the C++ demos, you can use SCons to compile the library:
```
git clone --recursive https://github.com/GodotNativeTools/godot-cpp
scons platform=PLATFORM
```
Where PLATFORM is: `windows`, `linux`, or `osx`.
### Updating the api.json
Our api.json file contains meta data of all the classes that are part of the Godot core and are needed to generate the C++ binding classes for use in GDNative modules.
This file is supplied with our godot_headers repository for your convinience but if you are running a custom build of Godot and need access to classes that have recent changes a new api.json file must be generated. You do this by starting your Godot executable with the following parameters:
```
$ godot --gdnative-generate-json-api api.json
```
Now copy the api.json file into your folder structure so its easy to access. **Note** the remark below for the extra ```custom_api_file``` command line parameter needed to tell scons where to find your file.
### Compiling the cpp bindings library
The final step is to compile our cpp bindings library:
```
$ cd godot-cpp
$ scons platform=<your platform> generate_bindings=yes
$ cd ..
```
> Replace `<your platform>` with either `windows`, `linux` or `osx`.
> Include `use_llvm=yes` for using clang++
> Include `target=runtime` to build a runtime build (windows only at the moment)
> The resulting library will be created in `godot-cpp/bin/`, take note of its name as it will be different depending on platform.
> If you want to use an alternative api.json file add `use_custom_api_file=yes custom_api_file=../api.json`, be sure to specify the correct location of where you placed your file.
### Compile the demos
A `Makefile` is provided in each demo to make the process more convenient.
This creates the file `libsimple` in the respective
subfolders in the `project/gdnative` directory.

View File

@@ -1,7 +0,0 @@
extends Control
onready var TestClass = preload("res://bin/testclass.gdns")
func _ready():
var test_object = TestClass.new()
test_object.test_method("Hello World")

View File

@@ -1,9 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Main.gd" type="Script" id=1]
[node name="Main" type="Control"]
margin_right = 40.0
margin_bottom = 40.0
script = ExtResource( 1 )

View File

@@ -1,2 +0,0 @@
all:
scons cpp_bindings="../../godot-cpp/" headers="../../godot-cpp/godot_headers/"

View File

@@ -1,65 +0,0 @@
#!python
import os
# platform= makes it in line with Godots scons file, keeping p for backwards compatibility
platform = ARGUMENTS.get("p", "linux")
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-cpp/godot_headers"))
godot_bindings_path = ARGUMENTS.get("cpp_bindings", os.getenv("CPP_BINDINGS", "godot-cpp"))
# default to debug build, must be same setting as used for cpp_bindings
target = ARGUMENTS.get("target", "debug")
if ARGUMENTS.get("use_llvm", "no") == "yes":
env["CXX"] = "clang++"
# put stuff that is the same for all first, saves duplication
if platform == "osx":
env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-arch", "x86_64"])
env.Append(LINKFLAGS=["-arch", "x86_64", "-framework", "Cocoa", "-Wl,-undefined,dynamic_lookup"])
elif platform == "linux":
env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-Wno-writable-strings"])
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
elif platform == "windows":
# need to add detection of msvc vs mingw, this is for msvc...
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/gen/",
godot_bindings_path + "/include/core/",
]
)
if target == "debug":
env.Append(LIBS=["libgodot-cpp.linux.debug.64"])
else:
env.Append(LIBS=["libgodot-cpp.linux.release.64"])
env.Append(LIBPATH=[godot_bindings_path + "/bin/"])
sources = []
add_sources(sources, "src")
library = env.SharedLibrary(target="bin/libconstructor", source=sources)
Default(library)

View File

@@ -1,16 +0,0 @@
[entry]
X11.64="res://bin/libconstructor.so"
X11.32="res://bin/libconstructor.so"
[dependencies]
X11.64=[ ]
X11.32=[ ]
[general]
singleton=false
load_once=true
symbol_prefix="godot_"
reloadable=true

View File

@@ -1,9 +0,0 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://bin/constructor.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "TestClass"
library = ExtResource( 1 )

View File

@@ -1,99 +0,0 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
radiance_size = 1
sky_top_color = Color( 0.301961, 0.403922, 0.909804, 1 )
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
sky_curve = 0.25
sky_energy = 1.0
ground_bottom_color = Color( 0.196078, 0.152941, 0.0980392, 1 )
ground_horizon_color = Color( 0.329412, 0.211765, 0.0627451, 1 )
ground_curve = 0.25
ground_energy = 1.0
sun_color = Color( 1, 1, 1, 1 )
sun_latitude = 35.0
sun_longitude = 0.0
sun_angle_min = 1.0
sun_angle_max = 100.0
sun_curve = 0.05
sun_energy = 16.0
texture_size = 0
[resource]
background_mode = 2
background_sky = SubResource( 1 )
background_sky_scale = 1.0
background_color = Color( 0, 0, 0, 1 )
background_energy = 1.0
background_canvas_max_layer = 0
ambient_light_color = Color( 0, 0, 0, 1 )
ambient_light_energy = 1.0
ambient_light_sky_contribution = 0.0
fog_enabled = false
fog_color = Color( 0.5, 0.6, 0.7, 1 )
fog_sun_color = Color( 1, 0.9, 0.7, 1 )
fog_sun_amount = 0.0
fog_depth_enabled = true
fog_depth_begin = 10.0
fog_depth_curve = 1.0
fog_transmit_enabled = false
fog_transmit_curve = 1.0
fog_height_enabled = false
fog_height_min = 0.0
fog_height_max = 100.0
fog_height_curve = 1.0
tonemap_mode = 0
tonemap_exposure = 1.0
tonemap_white = 1.0
auto_exposure_enabled = false
auto_exposure_scale = 0.4
auto_exposure_min_luma = 0.05
auto_exposure_max_luma = 8.0
auto_exposure_speed = 0.5
ss_reflections_enabled = false
ss_reflections_max_steps = 64
ss_reflections_fade_in = 0.15
ss_reflections_fade_out = 2.0
ss_reflections_depth_tolerance = 0.2
ss_reflections_roughness = true
ssao_enabled = false
ssao_radius = 1.0
ssao_intensity = 1.0
ssao_radius2 = 0.0
ssao_intensity2 = 1.0
ssao_bias = 0.01
ssao_light_affect = 0.0
ssao_color = Color( 0, 0, 0, 1 )
ssao_blur = true
dof_blur_far_enabled = false
dof_blur_far_distance = 10.0
dof_blur_far_transition = 5.0
dof_blur_far_amount = 0.1
dof_blur_far_quality = 1
dof_blur_near_enabled = false
dof_blur_near_distance = 2.0
dof_blur_near_transition = 1.0
dof_blur_near_amount = 0.1
dof_blur_near_quality = 1
glow_enabled = false
glow_levels/1 = false
glow_levels/2 = false
glow_levels/3 = true
glow_levels/4 = false
glow_levels/5 = true
glow_levels/6 = false
glow_levels/7 = false
glow_intensity = 0.8
glow_strength = 1.0
glow_bloom = 0.0
glow_blend_mode = 2
glow_hdr_treshold = 1.0
glow_hdr_scale = 2.0
glow_bicubic_upscale = false
adjustment_enabled = false
adjustment_brightness = 1.0
adjustment_contrast = 1.0
adjustment_saturation = 1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@@ -1,23 +0,0 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
name="cpp_constructors"
icon="res://icon.png"
[rendering]
viewport/default_environment="res://default_env.tres"

View File

@@ -1,49 +0,0 @@
#include <File.hpp>
#include <Reference.hpp>
#include <Timer.hpp>
#include <Ref.hpp>
#include <stdio.h>
using namespace godot;
class TestClass : public Reference {
GODOT_CLASS(TestClass, Reference)
int count;
public:
void _init() {
count = 34;
}
int test_method(String s) {
Godot::print(s);
count++;
Timer *t = new Timer;
t->set_wait_time(13.36 * count);
Godot::print(String::num_real(t->get_wait_time()));
delete t;
// test Ref<T>
Ref<File> file;
file.instance();
file->open("res://test.txt", File::WRITE);
file->close();
// ref should free the memory automatically
return count;
}
static void _register_methods() {
register_method("test_method", &TestClass::test_method);
}
};

View File

@@ -1,17 +0,0 @@
#include <Godot.hpp>
#include "TestClass.hpp"
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
godot::Godot::gdnative_init(o);
}
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
godot::Godot::gdnative_terminate(o);
}
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
godot::Godot::nativescript_init(handle);
godot::register_class<TestClass>();
}

View File

@@ -1,98 +0,0 @@
---
BasedOnStyle: LLVM
# Commented out parameters are those with the same value as base LLVM style
# We can uncomment them if we want to change their value, or enforce the
# chosen value in case the base style changes (initial sync: Clang 3.9.1).
...
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
# AlignConsecutiveAssignments: false
# AlignConsecutiveDeclarations: false
# AlignEscapedNewlinesLeft: false
# AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: false
# AlwaysBreakTemplateDeclarations: false
# BinPackArguments: true
# BinPackParameters: true
# BraceWrapping:
# AfterClass: false
# AfterControlStatement: false
# AfterEnum: false
# AfterFunction: false
# AfterNamespace: false
# AfterObjCDeclaration: false
# AfterStruct: false
# AfterUnion: false
# BeforeCatch: false
# BeforeElse: false
# IndentBraces: false
# BreakBeforeBinaryOperators: None
# BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
# BreakConstructorInitializersBeforeComma: false
# BreakAfterJavaFieldAnnotations: false
# BreakStringLiterals: true
ColumnLimit: 0
# CommentPragmas: '^ IWYU pragma:'
# ConstructorInitializerAllOnOneLineOrOnePerLine: false
# ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
# DerivePointerAlignment: false
# DisableFormat: false
# ExperimentalAutoDetectBinPacking: false
# ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*'
Priority: 3
# IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentWidth: 4
# IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: true
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: None
ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
# PenaltyBreakBeforeFirstCallParameter: 19
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakString: 1000
# PenaltyExcessCharacter: 1000000
# PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
# ReflowComments: true
SortIncludes: true
# SpaceAfterCStyleCast: false
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeParens: ControlStatements
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 4
UseTab: Always
...

View File

@@ -1,2 +0,0 @@
GDNative-demo.*
*.a

View File

@@ -1,87 +0,0 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://Player Red/playerRed_stand.png" type="Texture" id=1]
[ext_resource path="res://Player Red/playerRed_walk1.png" type="Texture" id=2]
[ext_resource path="res://Player Red/playerRed_walk2.png" type="Texture" id=3]
[ext_resource path="res://Player Red/playerRed_walk3.png" type="Texture" id=4]
[ext_resource path="res://Player Red/playerRed_fall.png" type="Texture" id=5]
[ext_resource path="res://Player Red/playerRed_up1.png" type="Texture" id=6]
[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]
[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 = ExtResource( 9 )
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 1 ) ],
"loop": false,
"name": "Default",
"speed": 5.0
}, {
"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 3 ) ],
"loop": true,
"name": "Run",
"speed": 5.0
}, {
"frames": [ ExtResource( 5 ) ],
"loop": false,
"name": "JumpDown",
"speed": 5.0
}, {
"frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ) ],
"loop": false,
"name": "JumpUp",
"speed": 8.0
} ]
[sub_resource type="CircleShape2D" id=2]
custom_solver_bias = 0.0
radius = 22.8354
[node name="Character" type="KinematicBody2D"]
scale = Vector2( 0.5, 0.5 )
input_pickable = false
collision_layer = 1
collision_mask = 1
collision/safe_margin = 0.08
script = SubResource( 4 )
_sections_unfolded = [ "Transform" ]
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 1 )
animation = "Default"
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 2 )
[node name="Ray0" type="RayCast2D" parent="."]
position = Vector2( -18, 0 )
enabled = true
exclude_parent = true
cast_to = Vector2( 0, 25 )
collision_layer = 1
type_mask = 15
[node name="Ray1" type="RayCast2D" parent="."]
position = Vector2( 19, 0 )
enabled = true
exclude_parent = true
cast_to = Vector2( 0, 25 )
collision_layer = 1
type_mask = 15

Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_fall.png-301bfd41d778b32114baf3c9c50ff2be.stex"
[deps]
source_file="res://Player Red/playerRed_fall.png"
dest_files=[ "res://.import/playerRed_fall.png-301bfd41d778b32114baf3c9c50ff2be.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_stand.png-af591b973e2c87f6a38b4a41e4833941.stex"
[deps]
source_file="res://Player Red/playerRed_stand.png"
dest_files=[ "res://.import/playerRed_stand.png-af591b973e2c87f6a38b4a41e4833941.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 613 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_up1.png-f260a896e5f77f9f0845c53613477c85.stex"
[deps]
source_file="res://Player Red/playerRed_up1.png"
dest_files=[ "res://.import/playerRed_up1.png-f260a896e5f77f9f0845c53613477c85.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_up2.png-87399f0c9fe53fc55fe801604850254a.stex"
[deps]
source_file="res://Player Red/playerRed_up2.png"
dest_files=[ "res://.import/playerRed_up2.png-87399f0c9fe53fc55fe801604850254a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 696 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_up3.png-95b2956869d268a117ea111914f90220.stex"
[deps]
source_file="res://Player Red/playerRed_up3.png"
dest_files=[ "res://.import/playerRed_up3.png-95b2956869d268a117ea111914f90220.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_walk1.png-ade6ae6ec480d525ec4bd65536c4f3dc.stex"
[deps]
source_file="res://Player Red/playerRed_walk1.png"
dest_files=[ "res://.import/playerRed_walk1.png-ade6ae6ec480d525ec4bd65536c4f3dc.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 665 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_walk2.png-dee2c8490b7429a8491012a77edabca6.stex"
[deps]
source_file="res://Player Red/playerRed_walk2.png"
dest_files=[ "res://.import/playerRed_walk2.png-dee2c8490b7429a8491012a77edabca6.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_walk3.png-1bd3d8c9ff5f381422a5ef2523fe18dc.stex"
[deps]
source_file="res://Player Red/playerRed_walk3.png"
dest_files=[ "res://.import/playerRed_walk3.png-1bd3d8c9ff5f381422a5ef2523fe18dc.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_walk4.png-6009a111ffdcb8be52e3e006cb9940b3.stex"
[deps]
source_file="res://Player Red/playerRed_walk4.png"
dest_files=[ "res://.import/playerRed_walk4.png-6009a111ffdcb8be52e3e006cb9940b3.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 629 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playerRed_walk5.png-23e13d3afa791a065240513219f17404.stex"
[deps]
source_file="res://Player Red/playerRed_walk5.png"
dest_files=[ "res://.import/playerRed_walk5.png-23e13d3afa791a065240513219f17404.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@@ -1,20 +0,0 @@
# 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.

View File

@@ -1,98 +0,0 @@
---
BasedOnStyle: LLVM
# Commented out parameters are those with the same value as base LLVM style
# We can uncomment them if we want to change their value, or enforce the
# chosen value in case the base style changes (initial sync: Clang 3.9.1).
...
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
# AlignConsecutiveAssignments: false
# AlignConsecutiveDeclarations: false
# AlignEscapedNewlinesLeft: false
# AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: false
# AlwaysBreakTemplateDeclarations: false
# BinPackArguments: true
# BinPackParameters: true
# BraceWrapping:
# AfterClass: false
# AfterControlStatement: false
# AfterEnum: false
# AfterFunction: false
# AfterNamespace: false
# AfterObjCDeclaration: false
# AfterStruct: false
# AfterUnion: false
# BeforeCatch: false
# BeforeElse: false
# IndentBraces: false
# BreakBeforeBinaryOperators: None
# BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
# BreakConstructorInitializersBeforeComma: false
# BreakAfterJavaFieldAnnotations: false
# BreakStringLiterals: true
ColumnLimit: 0
# CommentPragmas: '^ IWYU pragma:'
# ConstructorInitializerAllOnOneLineOrOnePerLine: false
# ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
# DerivePointerAlignment: false
# DisableFormat: false
# ExperimentalAutoDetectBinPacking: false
# ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*'
Priority: 3
# IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentWidth: 4
# IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: true
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: None
ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
# PenaltyBreakBeforeFirstCallParameter: 19
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakString: 1000
# PenaltyExcessCharacter: 1000000
# PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
# ReflowComments: true
SortIncludes: true
# SpaceAfterCStyleCast: false
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeParens: ControlStatements
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 4
UseTab: Always
...

View File

@@ -1,6 +0,0 @@
[submodule "cpp_bindings"]
path = cpp_bindings
url = http://github.com/GodotNativeTools/cpp_bindings/
[submodule "godot_headers"]
path = godot_headers
url = http://github.com/GodotNativeTools/godot_headers

View File

@@ -1,2 +0,0 @@
all:
scons cpp_bindings="../../../godot-cpp/" headers="../../../godot-cpp/godot_headers/"

View File

@@ -1,65 +0,0 @@
#!python
import os
# platform= makes it in line with Godots scons file, keeping p for backwards compatibility
platform = ARGUMENTS.get("p", "linux")
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-cpp/godot_headers"))
godot_bindings_path = ARGUMENTS.get("cpp_bindings", os.getenv("CPP_BINDINGS", "godot-cpp"))
# default to debug build, must be same setting as used for cpp_bindings
target = ARGUMENTS.get("target", "debug")
if ARGUMENTS.get("use_llvm", "no") == "yes":
env["CXX"] = "clang++"
# put stuff that is the same for all first, saves duplication
if platform == "osx":
env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-arch", "x86_64"])
env.Append(LINKFLAGS=["-arch", "x86_64", "-framework", "Cocoa", "-Wl,-undefined,dynamic_lookup"])
elif platform == "linux":
env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-Wno-writable-strings"])
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
elif platform == "windows":
# need to add detection of msvc vs mingw, this is for msvc...
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/gen/",
godot_bindings_path + "/include/core/",
godot_bindings_path + "/include/",
]
)
if target == "debug":
env.Append(LIBS=["libgodot-cpp.linux.debug.64"])
else:
env.Append(LIBS=["libgodot-cpp.linux.release.64"])
env.Append(LIBPATH=[godot_bindings_path + "/bin/"])
sources = []
add_sources(sources, "src")
library = env.SharedLibrary(target="bin/libkinematic_char", source=sources)
Default(library)

View File

@@ -1,17 +0,0 @@
[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=[]

View File

@@ -1,11 +0,0 @@
[gd_resource type="NativeScript" 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 )

View File

@@ -1,11 +0,0 @@
[gd_resource type="NativeScript" 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 )

View File

@@ -1,46 +0,0 @@
/**
* Copyright 2017 RameshRavone. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#include "colworld.h"
#include <Label.hpp>
using namespace godot;
ColWorld::ColWorld() {
}
ColWorld::~ColWorld() {
}
void ColWorld::_init() {
}
void ColWorld::_ready() {
get_node("princess")->connect("body_entered", this, "_on_princess_body_enter");
}
void ColWorld::_on_princess_body_enter(KinematicBody2D *body) {
if (body->get_name() == "Character") {
((Label *)get_node("youwin"))->show();
}
}
void ColWorld::_register_methods() {
register_method("_init", &ColWorld::_init);
register_method("_ready", &ColWorld::_ready);
register_method("_on_princess_body_enter", &ColWorld::_on_princess_body_enter);
}

View File

@@ -1,41 +0,0 @@
/**
* Copyright 2017 RameshRavone. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#ifndef COLWORLD_H
#define COLWORLD_H
#include <Godot.hpp>
#include <KinematicBody2D.hpp>
#include <Node2D.hpp>
namespace godot {
class ColWorld : public Node2D {
GODOT_CLASS(ColWorld, Node2D)
public:
ColWorld();
~ColWorld();
void _init();
void _ready();
void _on_princess_body_enter(KinematicBody2D *body);
static void _register_methods();
};
} // namespace godot
#endif // COLWORLD_H

View File

@@ -1,37 +0,0 @@
/**
* Copyright 2017 RameshRavone. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#include <Godot.hpp>
#include "colworld.h"
#include "player.h"
using namespace godot;
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options) {
Godot::gdnative_init(options);
}
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) {
Godot::gdnative_terminate(options);
}
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
Godot::nativescript_init(handle);
register_class<GDPlayer>();
register_class<ColWorld>();
}

View File

@@ -1,173 +0,0 @@
/**
* Copyright 2017 RameshRavone. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#include "player.h"
#include "colworld.h"
#include <AnimatedSprite.hpp>
#include <Input.hpp>
#include <cmath>
#include <ClassDB.hpp>
using namespace godot;
const static float _gravity = 400.0;
const static float _floor_angle_tolerance = 40.0;
const static float _walk_force = 500.0;
const static float _walk_min_speed = 10.0;
const static float _walk_max_speed = 200.0;
const static float _stop_force = 1300.0;
const static float _jump_speed = 200.0;
const static float _max_airborn_time = 0.2;
const static float _slide_stop_velocity = 1.0;
const static float _slide_stop_min_travel = 1.0;
template <typename T>
int sign(const T &val) {
return (val > 0) - (val < 0);
}
GDPlayer::GDPlayer() {
}
GDPlayer::~GDPlayer() {
}
void GDPlayer::_init() {
Vector2 _force = Vector2();
_jumping = false;
_on_air_time = 0.0;
_current_anim = "Default";
}
void GDPlayer::_ready() {
ray0 = ((RayCast2D *)get_node("Ray0"));
ray1 = ((RayCast2D *)get_node("Ray1"));
ray0->add_exception(this);
ray1->add_exception(this);
connect("move", this, "_move");
}
void GDPlayer::moving() {
Godot::print("Player Jumping");
}
void GDPlayer::_physics_process(const float delta) {
Vector2 _force = Vector2(0, _gravity);
bool left = Input::get_singleton()->is_action_pressed("ui_left");
bool right = Input::get_singleton()->is_action_pressed("ui_right");
bool jump = Input::get_singleton()->is_action_pressed("ui_up");
bool stop = true;
if (left) {
if (_velocity.x <= _walk_min_speed && _velocity.x > -_walk_max_speed) {
_force.x -= _walk_force;
stop = false;
}
} else if (right) {
if (_velocity.x >= -_walk_min_speed && _velocity.x < _walk_max_speed) {
_force.x += _walk_force;
stop = false;
}
}
if (stop) {
float vsign = sign(_velocity.x);
float vlen = std::abs(_velocity.x);
vlen -= _stop_force * delta;
if (vlen < 0) {
vlen = 0;
}
_velocity.x = (vlen * vsign);
}
// Integrate forces to velocity
_velocity += _force * delta;
// Integrate velocity into motion and move
_velocity = move_and_slide(_velocity, Vector2(0, -1));
bool floor_colliding = (ray0->is_colliding() || ray1->is_colliding());
if (is_on_floor() || floor_colliding) {
_on_air_time = 0;
}
if (_on_air_time < _max_airborn_time && jump && !_prev_jump_pressed && !_jumping) {
_velocity.y = -_jump_speed;
_jumping = false;
emit_signal("move");
}
_on_air_time += delta;
_prev_jump_pressed = jump;
/**
* @brief Animating
*
* The following show's how to get the child nodes and access there functions..
*/
bool animating = false;
if (left) {
((AnimatedSprite *)get_node("AnimatedSprite"))->set_flip_h(true);
if (floor_colliding) {
_current_anim = "Run";
}
animating = true;
}
if (right) {
((AnimatedSprite *)get_node("AnimatedSprite"))->set_flip_h(false);
if (floor_colliding) {
_current_anim = "Run";
}
animating = true;
}
if (!floor_colliding) {
if (_velocity.y > 0) {
_current_anim = "JumpDown";
}
if (_velocity.y < 0) {
_current_anim = "JumpUp";
}
} else if (!animating) {
_current_anim = "Default";
}
((AnimatedSprite *)get_node("AnimatedSprite"))->play(_current_anim);
}
void GDPlayer::_register_methods() {
register_method((char *)"_init", &GDPlayer::_init);
register_method((char *)"_ready", &GDPlayer::_ready);
register_method((char *)"_move", &GDPlayer::moving);
register_method((char *)"_physics_process", &GDPlayer::_physics_process);
register_signal<GDPlayer>("move");
}

View File

@@ -1,56 +0,0 @@
/**
* Copyright 2017 RameshRavone. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#ifndef PLAYER_H
#define PLAYER_H
#include <Godot.hpp>
#include <InputEvent.hpp>
#include <RayCast2D.hpp>
#include <KinematicBody2D.hpp>
using namespace godot;
class GDPlayer : public KinematicBody2D {
GODOT_CLASS(GDPlayer, KinematicBody2D)
public:
GDPlayer();
~GDPlayer();
void _init();
void _ready();
void moving();
void _physics_process(const float delta);
static void _register_methods();
private:
bool _jumping;
bool _prev_jump_pressed;
float _on_air_time;
Vector2 _velocity;
String _current_anim;
RayCast2D *ray0;
RayCast2D *ray1;
};
#endif // PLAYER_H_

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/circle.png-10953cad44a8947fbdd4128a631e9e52.stex"
[deps]
source_file="res://circle.png"
dest_files=[ "res://.import/circle.png-10953cad44a8947fbdd4128a631e9e52.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/long_obstacle.png-1b33440a15b4db156b2a9ec7e9a2a80e.stex"
[deps]
source_file="res://long_obstacle.png"
dest_files=[ "res://.import/long_obstacle.png-1b33440a15b4db156b2a9ec7e9a2a80e.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/obstacle.png-dfb3e99d3af573251007cdf5e1c252b9.stex"
[deps]
source_file="res://obstacle.png"
dest_files=[ "res://.import/obstacle.png-dfb3e99d3af573251007cdf5e1c252b9.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

View File

@@ -1,31 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/princess.png-9b4caf2cfe324ae3734249d5b559d39d.stex"
[deps]
source_file="res://princess.png"
dest_files=[ "res://.import/princess.png-9b4caf2cfe324ae3734249d5b559d39d.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@@ -1,68 +0,0 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[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"
[display]
window/size/width=530
window/size/height=495
stretch/aspect="keep"
stretch/mode="2d"
window/height=495
window/width=530
[gdnative]
singletons=[ ]
[input]
jump={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
]
}
move_bottom={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
]
}
move_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
]
}
[memory]
multithread/thread_rid_pool_prealloc=60

30
cpp/simple/README.md Normal file
View File

@@ -0,0 +1,30 @@
# Simple GDNative C++ demo
This is a small example using C++ to create a GDNative script
that just showcases some very simple bare bones calls.
Language: C++
Renderer: GLES 2
Dependencies:
* You need [godot-cpp](https://github.com/godotengine/godot-cpp),
this is now a Git submodule of this repo.
* `clang`, `gcc`, or any decent C++ compiler that's C++14 compatible.
## Compiling
You can use SCons to compile the library:
```
scons platform=PLATFORM
```
Where PLATFORM is: `windows`, `linux`, or `osx`.
This creates the file `libsimple` in the respective
subfolders in the `project/gdnative` directory.
## Screenshots
![Screenshot](screenshots/screenshot.png)

View File

@@ -1,18 +0,0 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
radiance_size = 4
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
sky_curve = 0.25
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
ground_curve = 0.01
sun_energy = 16.0
[resource]
background_mode = 2
background_sky = SubResource( 1 )
fog_height_min = 0.0
fog_height_max = 100.0
ssao_quality = 0

View File

@@ -24,7 +24,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Sprite" type="Sprite" parent="."]
[node name="SimpleSprite" type="Sprite" parent="."]
position = Vector2( 100, 100 )
texture = ExtResource( 2 )
script = ExtResource( 3 )

View File

@@ -14,11 +14,14 @@ _global_script_class_icons={
[application]
config/name="New Game Project"
config/name="Simple GDNative C++ demo"
run/main_scene="res://main.tscn"
config/icon="res://icon.png"
[rendering]
quality/driver/fallback_to_gles2=true
environment/default_environment="res://default_env.tres"
quality/driver/driver_name="GLES2"
quality/intended_usage/framebuffer_allocation=0
quality/intended_usage/framebuffer_allocation.mobile=0
vram_compression/import_etc=true
vram_compression/import_etc2=false

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -19,16 +19,17 @@ void SimpleSprite::_register_methods() {
}
// `_init` doesn't need to be registered in `_register_methods`.
// `_init` is always required, if you exclude it then Godot will crash.
void SimpleSprite::_init() {
godot::Godot::print("A SimpleSprite was initialized in GDNative!");
}
void SimpleSprite::_process(double delta) {
void SimpleSprite::_process(double p_delta) {
godot::Input *input = godot::Input::get_singleton();
godot::Vector2 input_dir(0, 0);
input_dir.x = input->get_action_strength("ui_right") - input->get_action_strength("ui_left");
input_dir.y = input->get_action_strength("ui_down") - input->get_action_strength("ui_up");
set_position(get_position() + input_dir.normalized() * delta * 300);
set_position(get_position() + input_dir.normalized() * p_delta * 300);
}

View File

@@ -1,3 +1,6 @@
#ifndef SIMPLE_H
#define SIMPLE_H
#include <Godot.hpp>
#include <Reference.hpp>
@@ -24,5 +27,7 @@ public:
void _init();
void _process(double delta);
void _process(double p_delta);
};
#endif // SIMPLE_H