#include "example.h"
#include <godot_cpp/core/class_db.hpp>

using namespace godot;

void Example::_bind_methods()
{
	ClassDB::bind_method(D_METHOD("get_amplitude"), &Example::get_amplitude);
	ClassDB::bind_method(D_METHOD("set_amplitude","p_amplitude"), &Example::set_amplitude);
	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "amplitude"), "set_amplitude", "get_amplitude");
	
	ClassDB::bind_method(D_METHOD("get_speed"), &Example::get_speed);
	ClassDB::bind_method(D_METHOD("set_speed","p_speed"), &Example::set_speed);
	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed", PROPERTY_HINT_RANGE,"0,20,0.01"), "set_speed", "get_speed");
}

Example::Example()
{
	time_passed=0.0;
	amplitude=10.0;
	speed=1.0;
}
Example::~Example(){}
void Example::_process(double delta)
{
	time_passed+=speed*delta;
	Vector2 new_position=Vector2(amplitude+(amplitude*sin(time_passed*2.0)),amplitude+(amplitude*cos(time_passed*1.5)));
	set_position(new_position);
}

void Example::set_amplitude(const double p_amplitude) { amplitude=p_amplitude; }
double Example::get_amplitude() const { return amplitude; }

void Example::set_speed(const double p_speed) { speed=p_speed; }
double Example::get_speed() const { return speed; }