Merge pull request #34 from godotengine/cpp-nativescript-1-1

Merge "cpp-nativescript-1-1" into master
This commit is contained in:
Aaron Franke
2020-08-13 20:47:05 -05:00
committed by GitHub
49 changed files with 1079 additions and 279 deletions

150
.gitignore vendored
View File

@@ -1,12 +1,148 @@
*.o
# Godot-specific ignores
.import/
export.cfg
export_presets.cfg
.fscache
logs/
# Mono-specific ignores
.mono/
# System/tool-specific ignores
.directory
*.dblite
*~
logs
*.os
*.exp
# Vim temp files
*.swo
*.swp
# QT project files
*.config
*.creator
*.creator.*
*.files
*.includes
# Eclipse CDT files
.cproject
.settings/
# Geany/geany-plugins files
*.geany
.geanyprj
# User-specific files
*.suo
*.user
*.sln.docstates
*.sln
*.vcxproj*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.opendb
*.VC.VC.opendb
enc_temp_folder/
# Visual Studio profiler
*.psess
*.vsp
*.vspx
#Kdevelop project files
*.kdev4
# CodeLite project files
*.project
*.workspace
.codelite/
# TFS 2012 Local Workspace
$tf/
# Microsoft Fakes
FakesAssemblies/
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
logo.h
*.autosave
# https://github.com/github/gitignore/blob/master/Global/Tags.gitignore
# Ignore tags created by etags, ctags, gtags (GNU global) and cscope
TAGS
!TAGS/
tags
*.tags
!tags/
gtags.files
GTAGS
GRTAGS
GPATH
cscope.files
cscope.out
cscope.in.out
cscope.po.out
godot.creator.*
projects/
platform/windows/godot_res.res
# Visual Studio 2017 and Visual Studio Code workspace folder
/.vs
/.vscode
# Scons progress indicator
.scons_node_count
# GDNative ignores
cpp_bindings/
godot_headers/
godot-cpp/
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
.import
*.import
*.dblite
*.dll
*.exp
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
*.obj
logs
# Executables
*.exe
*.out
*.app

44
Readme.md Normal file
View File

@@ -0,0 +1,44 @@
## C++
### Initial setup
You need to clone the GDNative C++ bindings in the root of this project:
```
git clone --recursive https://github.com/GodotNativeTools/godot-cpp
```
### 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.

2
cpp/SimpleDemo/Makefile Normal file
View File

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

View File

@@ -11,8 +11,8 @@ 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"))
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")
@@ -41,9 +41,13 @@ def add_sources(sources, dir):
if f.endswith(".cpp"):
sources.append(dir + "/" + f)
env.Append(CPPPATH=[godot_headers_path, godot_bindings_path + '/include/', godot_bindings_path + '/include/core/'])
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(LIBS=['godot_cpp_bindings'])
env.Append(LIBPATH=[ godot_bindings_path + '/bin/' ])
sources = []

View File

@@ -65,6 +65,7 @@ ssao_radius2 = 0.0
ssao_intensity2 = 1.0
ssao_bias = 0.01
ssao_light_affect = 0.0
ssao_ao_channel_affect = 0.0
ssao_color = Color( 0, 0, 0, 1 )
ssao_quality = 0
ssao_blur = 3

View File

@@ -0,0 +1,31 @@
[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,13 +1,19 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://main.gd" type="Script" id=1]
[ext_resource path="res://icon.png" type="Texture" id=2]
[ext_resource path="res://bin/simple.gdnlib" type="GDNativeLibrary" id=3]
[node name="Node" type="Node" index="0"]
[sub_resource type="NativeScript" id=1]
resource_name = "SimpleSprite"
class_name = "SimpleSprite"
library = ExtResource( 3 )
[node name="Node" type="Node"]
script = ExtResource( 1 )
[node name="Button" type="Button" parent="." index="0"]
[node name="Button" type="Button" parent="."]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@@ -17,6 +23,7 @@ margin_top = 208.0
margin_right = 682.0
margin_bottom = 325.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
@@ -30,8 +37,7 @@ text = "Press me"
flat = false
align = 1
[node name="Label" type="Label" parent="." index="1"]
[node name="Label" type="Label" parent="."]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@@ -41,6 +47,7 @@ margin_top = 360.0
margin_right = 662.0
margin_bottom = 374.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
@@ -50,6 +57,8 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )
script = SubResource( 1 )
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]

View File

@@ -6,7 +6,12 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=3
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]

View File

@@ -1,5 +1,7 @@
#include "Simple.hpp"
#include "Input.hpp"
void Simple::_register_methods()
{
godot::register_method("get_data", &Simple::get_data);
@@ -14,3 +16,33 @@ godot::String Simple::get_data() const
{
return data;
}
void SimpleSprite::_register_methods()
{
godot::register_method("_process", &SimpleSprite::_process);
}
void SimpleSprite::_init()
{
godot::Godot::print("Wheeeeey");
}
void SimpleSprite::_process(double delta)
{
godot::Vector2 input_dir(0, 0);
if (godot::Input::get_singleton()->is_action_pressed("ui_right")) {
input_dir.x += 1;
}
if (godot::Input::get_singleton()->is_action_pressed("ui_left")) {
input_dir.x -= 1;
}
if (godot::Input::get_singleton()->is_action_pressed("ui_down")) {
input_dir.y += 1;
}
if (godot::Input::get_singleton()->is_action_pressed("ui_up")) {
input_dir.y -= 1;
}
set_position(get_position() + input_dir.normalized() * delta * 300);
}

View File

@@ -1,9 +1,10 @@
#include <Godot.hpp>
#include <Reference.hpp>
#include <Sprite.hpp>
class Simple : public godot::GodotScript<godot::Reference> {
GODOT_CLASS(Simple)
class Simple : public godot::Reference {
GODOT_CLASS(Simple, godot::Reference)
godot::String data;
public:
@@ -14,3 +15,14 @@ public:
godot::String get_data() const;
};
class SimpleSprite : public godot::Sprite {
GODOT_CLASS(SimpleSprite, godot::Sprite)
public:
static void _register_methods();
void _init();
void _process(double delta);
};

View File

@@ -18,4 +18,5 @@ extern "C" void GDN_EXPORT godot_nativescript_init(void *handle)
godot::register_class<Simple>();
godot::register_class<SimpleSprite>();
}

View File

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

View File

@@ -3,11 +3,7 @@
[ext_resource path="res://Main.gd" type="Script" id=1]
[node name="Main" type="Control"]
margin_right = 40.0
margin_bottom = 40.0
rect_clip_content = false
mouse_filter = 0
script = ExtResource( 1 )

View File

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

View File

@@ -0,0 +1,57 @@
#!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,21 +0,0 @@
[gd_resource type="GDNativeScript" load_steps=2 format=2]
[sub_resource type="GDNativeLibrary" id=1]
platform/unix = ""
platform/x11 = "res://lib/libtest.so"
platform/server = ""
platform/android = ""
platform/haiku = ""
platform/mac = ""
platform/ios = ""
platform/osx = ""
platform/html5 = ""
platform/windows = ""
platform/uwp = ""
[resource]
library = SubResource( 1 )
script_name = "TestClass"

View File

@@ -0,0 +1,16 @@
[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

@@ -0,0 +1,9 @@
[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

@@ -0,0 +1,31 @@
[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,16 +1,23 @@
; 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:
;
; 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,36 +0,0 @@
#!python
import os
env = Environment()
if ARGUMENTS.get("use_llvm", "no") == "yes":
env["CXX"] = "clang++"
platform = ARGUMENTS.get("p", "linux")
def add_sources(sources, dir):
for f in os.listdir(dir):
if f.endswith(".cpp"):
sources.append(dir + "/" + f)
if platform == "linux":
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-Wno-writable-strings'])
env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\''])
env.Append(CPPPATH=['/usr/include/godot/', '/usr/include/godot/godot_cpp/', '/usr/include/godot/godot_cpp/core'])
env.Append(LIBS=['godot_cpp_core', 'godot_cpp_bindings'])
env.Append(LIBPATH=["../lib"])
if platform == "windows":
env.Append(LIBS=['godot.windows.tools.64'])
sources = ["init.cpp"]
library = env.SharedLibrary(target='../lib/test', source=sources)
Default(library)

View File

@@ -0,0 +1,52 @@
#include <Reference.hpp>
#include <Timer.hpp>
#include <File.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,60 +1,20 @@
#include <Godot.hpp>
#include <Reference.hpp>
#include <Timer.hpp>
#include <File.hpp>
#include "TestClass.hpp"
#include <Ref.hpp>
#include <stdio.h>
using namespace godot;
class TestClass : public GodotScript<Reference> {
GODOT_CLASS(TestClass)
int count;
public:
int test_method(const String s)
{
Godot::print(s);
count++;
Timer *t = new Timer;
t->set_wait_time(13.36 * count);
// sorry, no String::num() yet
char str[128];
snprintf(str, 128, "wait time: %f", t->get_wait_time());
Godot::print(String(str));
delete t;
// test Ref<T>
Ref<File> file = new File;
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);
}
};
GODOT_NATIVE_INIT(godot_native_init_options *options)
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o)
{
register_class<TestClass>();
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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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,3 +1,2 @@
all:
scons cpp_bindings=../../../../godot-cpp/ headers=../../../../godot_headers/
scons cpp_bindings="../../../godot-cpp/" headers="../../../godot-cpp/godot_headers/"

View File

@@ -11,8 +11,8 @@ 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"))
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")
@@ -41,9 +41,12 @@ def add_sources(sources, 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/gen/', godot_bindings_path + '/include/core/', godot_bindings_path + '/include/'])
env.Append(LIBS=['godot_cpp_bindings'])
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 = []

View File

@@ -14,7 +14,7 @@
* limitations under the License.
**/
#include <colworld.h>
#include "colworld.h"
#include <Label.hpp>
using namespace godot;
@@ -29,18 +29,18 @@ void ColWorld::_init() {
}
void ColWorld::_ready() {
owner->get_node("princess")->connect("body_entered", owner, "_on_princess_body_enter");
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 *)owner->get_node("youwin"))->show();
((Label *)get_node("youwin"))->show();
}
}
void ColWorld::_register_methods() {
register_method((char *)"_init", &ColWorld::_init);
register_method((char *)"_ready", &ColWorld::_ready);
register_method("_init", &ColWorld::_init);
register_method("_ready", &ColWorld::_ready);
register_method((char *)"_on_princess_body_enter", &ColWorld::_on_princess_body_enter);
register_method("_on_princess_body_enter", &ColWorld::_on_princess_body_enter);
}

View File

@@ -23,8 +23,8 @@
namespace godot {
class ColWorld : public GodotScript<Node2D> {
GODOT_CLASS(ColWorld)
class ColWorld : public Node2D {
GODOT_CLASS(ColWorld, Node2D)
public:
ColWorld();

View File

@@ -16,8 +16,8 @@
#include <Godot.hpp>
#include <colworld.h>
#include <player.h>
#include "colworld.h"
#include "player.h"
using namespace godot;

View File

@@ -14,13 +14,13 @@
* limitations under the License.
**/
#include <player.h>
#include "player.h"
#include "colworld.h"
#include <AnimatedSprite.hpp>
#include <Input.hpp>
#include <cmath>
#include <colworld.h>
#include <ClassDB.hpp>
using namespace godot;
@@ -58,13 +58,13 @@ void GDPlayer::_init() {
}
void GDPlayer::_ready() {
ray0 = ((RayCast2D *)owner->get_node("Ray0"));
ray1 = ((RayCast2D *)owner->get_node("Ray1"));
ray0 = ((RayCast2D *)get_node("Ray0"));
ray1 = ((RayCast2D *)get_node("Ray1"));
ray0->add_exception(owner);
ray1->add_exception(owner);
ray0->add_exception(this);
ray1->add_exception(this);
owner->connect("move", owner, "_move");
connect("move", this, "_move");
}
void GDPlayer::moving() {
@@ -74,9 +74,9 @@ void GDPlayer::moving() {
void GDPlayer::_physics_process(const float delta) {
Vector2 _force = Vector2(0, _gravity);
bool left = Input::is_action_pressed("ui_left");
bool right = Input::is_action_pressed("ui_right");
bool jump = Input::is_action_pressed("ui_up");
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;
@@ -108,18 +108,18 @@ void GDPlayer::_physics_process(const float delta) {
// Integrate forces to velocity
_velocity += _force * delta;
// Integrate velocity into motion and move
_velocity = owner->move_and_slide(_velocity, Vector2(0, -1));
_velocity = move_and_slide(_velocity, Vector2(0, -1));
bool floor_colliding = (ray0->is_colliding() || ray1->is_colliding());
if (owner->is_on_floor() || floor_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;
owner->emit_signal("move");
emit_signal("move");
}
_on_air_time += delta;
@@ -134,14 +134,14 @@ void GDPlayer::_physics_process(const float delta) {
bool animating = false;
if (left) {
((AnimatedSprite *)owner->get_node("AnimatedSprite"))->set_flip_h(true);
((AnimatedSprite *)get_node("AnimatedSprite"))->set_flip_h(true);
if (floor_colliding) {
_current_anim = "Run";
}
animating = true;
}
if (right) {
((AnimatedSprite *)owner->get_node("AnimatedSprite"))->set_flip_h(false);
((AnimatedSprite *)get_node("AnimatedSprite"))->set_flip_h(false);
if (floor_colliding) {
_current_anim = "Run";
}
@@ -159,7 +159,7 @@ void GDPlayer::_physics_process(const float delta) {
_current_anim = "Default";
}
((AnimatedSprite *)owner->get_node("AnimatedSprite"))->play(_current_anim);
((AnimatedSprite *)get_node("AnimatedSprite"))->play(_current_anim);
}
void GDPlayer::_register_methods() {

View File

@@ -25,8 +25,8 @@
using namespace godot;
class GDPlayer : public GodotScript<KinematicBody2D> {
GODOT_CLASS(GDPlayer)
class GDPlayer : public KinematicBody2D {
GODOT_CLASS(GDPlayer, KinematicBody2D)
public:
GDPlayer();

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

View File

@@ -0,0 +1,31 @@
[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

@@ -6,7 +6,12 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=3
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
@@ -32,16 +37,31 @@ singletons=[ ]
[input]
jump=[ 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)
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=[ 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_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=[ 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_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=[ 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_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=[ 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)
}
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]