Compare commits
4 Commits
cdcc23c50a
...
a4d062ea04
| Author | SHA1 | Date |
|---|---|---|
|
|
a4d062ea04 | |
|
|
52ae094087 | |
|
|
e77fe832f0 | |
|
|
f4fd083a1a |
|
|
@ -0,0 +1,4 @@
|
||||||
|
[submodule "evolve-die-repeat/thirdparty/godot-cpp"]
|
||||||
|
path = evolve-die-repeat/thirdparty/godot-cpp
|
||||||
|
url = https://github.com/godotengine/godot-cpp.git
|
||||||
|
branch = 4.5
|
||||||
25
README.md
25
README.md
|
|
@ -1,2 +1,25 @@
|
||||||
# notSpore
|
# Evolve Die Repeat TODO: The name is a work in progress
|
||||||
|
|
||||||
|
This is currently quite empty.
|
||||||
|
|
||||||
|
## C++ setup
|
||||||
|
From anywhere in proejct:
|
||||||
|
```bash
|
||||||
|
git submodule update --init --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
In `thirdparty`:
|
||||||
|
```bash
|
||||||
|
godot --headless --dump-extension-api
|
||||||
|
```
|
||||||
|
|
||||||
|
To compile the cpp extension, run this from `thirdparty/godot-cpp`:
|
||||||
|
```bash
|
||||||
|
scons platform=linux target=template_debug generate_bindings=yes custom_api_file=../extension_api.json -j8
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, to compile and extern local `.cpp` files, run this from `thirdparty`:
|
||||||
|
```bash
|
||||||
|
scons platform=linux target=template_debug -j8
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
extends Label
|
||||||
|
|
||||||
|
var counter := Test.new() # C++ class
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
text += str(counter.get_counter())
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
#if Input.is_action_just_pressed("ui_accept"):
|
||||||
|
counter.increment()
|
||||||
|
var baseText := text
|
||||||
|
baseText = baseText.left(baseText.length() - str(counter.get_counter()).length())
|
||||||
|
text = baseText + str(counter.get_counter())
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://ceut2lrvkns75
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
[gd_scene format=3 uid="uid://b55w56d4twno1"]
|
[gd_scene load_steps=2 format=3 uid="uid://b55w56d4twno1"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://ceut2lrvkns75" path="res://debug_label.gd" id="1_quyes"]
|
||||||
|
|
||||||
[node name="MolecularStag" type="Node2D"]
|
[node name="MolecularStag" type="Node2D"]
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="DebugLabel" type="Label" parent="."]
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
offset_bottom = 23.0
|
offset_bottom = 23.0
|
||||||
text = "Debug: You made it into the game!"
|
text = "Debug: You made it into the game!
|
||||||
|
This is running from C++: "
|
||||||
|
script = ExtResource("1_quyes")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
bin
|
||||||
|
*.uid
|
||||||
|
*sconsign.dblite
|
||||||
|
**.os
|
||||||
|
|
||||||
|
godot-cpp/bin/
|
||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import os
|
||||||
|
from SCons.Script import DefaultEnvironment, ARGUMENTS, Glob, Dir
|
||||||
|
|
||||||
|
env = DefaultEnvironment()
|
||||||
|
platform = ARGUMENTS.get("platform", "linux")
|
||||||
|
target = ARGUMENTS.get("target", "template_debug") # or template_release
|
||||||
|
arch = ARGUMENTS.get("arch", "x86_64")
|
||||||
|
|
||||||
|
HERE = Dir(".").abspath
|
||||||
|
GODOTCPP = os.path.join(HERE, "godot-cpp")
|
||||||
|
|
||||||
|
inc_paths = [
|
||||||
|
os.path.join(GODOTCPP, "include"),
|
||||||
|
os.path.join(GODOTCPP, "gen", "include"),
|
||||||
|
]
|
||||||
|
for extra in ("godot-headers", "gdextension"):
|
||||||
|
p = os.path.join(GODOTCPP, extra)
|
||||||
|
if os.path.isdir(p):
|
||||||
|
inc_paths.append(p)
|
||||||
|
|
||||||
|
env.Append(CPPPATH=inc_paths)
|
||||||
|
env.Append(LIBPATH=[os.path.join(GODOTCPP, "bin")])
|
||||||
|
env.Append(CXXFLAGS=["-std=c++17", "-fPIC"])
|
||||||
|
|
||||||
|
env.Append(LIBS=[f"godot-cpp.{platform}.{target}.{arch}"])
|
||||||
|
|
||||||
|
outdir = os.path.join(HERE, "bin")
|
||||||
|
os.makedirs(outdir, exist_ok=True)
|
||||||
|
soname = f"gol.{platform}.{'debug' if target == 'template_debug' else 'release'}.{arch}"
|
||||||
|
|
||||||
|
env.SharedLibrary(target=os.path.join(outdir, soname), source=Glob("src/*.cpp"))
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
[configuration]
|
||||||
|
entry_symbol = "gol_library_init"
|
||||||
|
compatibility_minimum = "4.5" ; required in 4.5+
|
||||||
|
reloadable = true
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
linux.debug.x86_64 = "res://thirdparty/bin/libgol.linux.debug.x86_64"
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit e83fd0904c13356ed1d4c3d09f8bb9132bdc6b77
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
|
||||||
|
#include <gdextension_interface.h>
|
||||||
|
#include <godot_cpp/classes/ref_counted.hpp>
|
||||||
|
#include <godot_cpp/core/class_db.hpp>
|
||||||
|
#include <godot_cpp/core/defs.hpp>
|
||||||
|
#include <godot_cpp/godot.hpp>
|
||||||
|
|
||||||
|
using namespace godot;
|
||||||
|
|
||||||
|
class Test : public RefCounted {
|
||||||
|
GDCLASS(Test, RefCounted);
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
static void _bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("increment"), &Test::increment);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_counter"), &Test::get_counter);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_counter", "value"), &Test::set_counter);
|
||||||
|
ClassDB::add_property("Test", PropertyInfo(Variant::INT, "counter"),
|
||||||
|
"set_counter", "get_counter");
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
int increment() {
|
||||||
|
counter += 1;
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_counter() const { return counter; }
|
||||||
|
|
||||||
|
void set_counter(int p_value) { counter = p_value; }
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" GDExtensionBool GDE_EXPORT
|
||||||
|
gol_library_init(GDExtensionInterfaceGetProcAddress get_proc_address,
|
||||||
|
GDExtensionClassLibraryPtr library,
|
||||||
|
GDExtensionInitialization *r_initialization) {
|
||||||
|
|
||||||
|
static GDExtensionBinding::InitObject init(get_proc_address, library,
|
||||||
|
r_initialization);
|
||||||
|
|
||||||
|
init.register_initializer([](ModuleInitializationLevel p_level) {
|
||||||
|
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClassDB::register_class<Test>();
|
||||||
|
});
|
||||||
|
|
||||||
|
init.register_terminator([](ModuleInitializationLevel /*p_level*/) {
|
||||||
|
// no-op
|
||||||
|
});
|
||||||
|
|
||||||
|
init.set_minimum_library_initialization_level(
|
||||||
|
MODULE_INITIALIZATION_LEVEL_SCENE);
|
||||||
|
return init.init();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue