generated from Persson-dev/Godot-Xmake
Initial commit
This commit is contained in:
28
src/gdexample.cpp
Normal file
28
src/gdexample.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
#include "gdexample.h"
|
||||
#include <godot_cpp/core/class_db.hpp>
|
||||
|
||||
using namespace godot;
|
||||
|
||||
void GDExample::_bind_methods() {
|
||||
// ClassDB::bind_method(D_METHOD("_process", "delta"), &GDExample::_process);
|
||||
}
|
||||
|
||||
GDExample::GDExample()
|
||||
{
|
||||
time_passed = 0.0;
|
||||
|
||||
}
|
||||
|
||||
GDExample::~GDExample() {}
|
||||
|
||||
void GDExample::_process(float delta)
|
||||
{
|
||||
time_passed += delta;
|
||||
|
||||
auto new_position = Vector2(
|
||||
10.0 + (10.0 * sin(time_passed * 2.0)),
|
||||
10.0 + (10.0 * cos(time_passed * 1.5)));
|
||||
|
||||
set_position(new_position);
|
||||
}
|
||||
24
src/gdexample.h
Normal file
24
src/gdexample.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef GDEXAMPLE_H
|
||||
#define GDEXAMPLE_H
|
||||
|
||||
#include <godot_cpp/classes/sprite2d.hpp>
|
||||
|
||||
namespace godot
|
||||
{
|
||||
class GDExample : public Sprite2D
|
||||
{
|
||||
GDCLASS(GDExample, Sprite2D)
|
||||
private:
|
||||
double time_passed;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
GDExample();
|
||||
~GDExample();
|
||||
|
||||
void _process(float delta);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
44
src/register_types.cpp
Normal file
44
src/register_types.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "register_types.h"
|
||||
|
||||
#include "gdexample.h"
|
||||
|
||||
#include <gdextension_interface.h>
|
||||
#include <godot_cpp/core/defs.hpp>
|
||||
#include <godot_cpp/godot.hpp>
|
||||
|
||||
using namespace godot;
|
||||
|
||||
void initialize_example_module(ModuleInitializationLevel p_level)
|
||||
{
|
||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClassDB::register_class<GDExample>();
|
||||
}
|
||||
|
||||
void uninitialize_example_module(ModuleInitializationLevel p_level)
|
||||
{
|
||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
GDExtensionBool GDE_EXPORT library_init(
|
||||
GDExtensionInterfaceGetProcAddress p_get_proc,
|
||||
const GDExtensionClassLibraryPtr p_library,
|
||||
GDExtensionInitialization *r_initialization)
|
||||
{
|
||||
godot::GDExtensionBinding::InitObject init_obj(p_get_proc, p_library, r_initialization);
|
||||
|
||||
init_obj.register_initializer(initialize_example_module);
|
||||
init_obj.register_terminator(uninitialize_example_module);
|
||||
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
|
||||
|
||||
return init_obj.init();
|
||||
}
|
||||
}
|
||||
11
src/register_types.h
Normal file
11
src/register_types.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef GDEXAMPLE_REGISTER_TYPES_H
|
||||
#define GDEXAMPLE_REGISTER_TYPES_H
|
||||
|
||||
#include <godot_cpp/core/class_db.hpp>
|
||||
|
||||
using namespace godot;
|
||||
|
||||
void initialize_example_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_example_module(ModuleInitializationLevel p_level);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user