From ea2e6fc13cdc9f047722473b365e2e40d86ec2f9 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 16 May 2024 08:43:45 +0200 Subject: [PATCH] feat: created CarPhysics class --- src/car_physics.cpp | 16 ++++++++++++++++ src/car_physics.hpp | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/car_physics.cpp create mode 100644 src/car_physics.hpp diff --git a/src/car_physics.cpp b/src/car_physics.cpp new file mode 100644 index 0000000..410c7c0 --- /dev/null +++ b/src/car_physics.cpp @@ -0,0 +1,16 @@ +#include "car_physics.hpp" +namespace godot { +void CarPhysics::_bind_methods() { +#define CLASSNAME CarPhysics +void CarPhysics::_enter_tree() { + this->set_use_custom_integrator(true); +} + +void CarPhysics::_integrate_forces(PhysicsDirectBodyState3D *state) { +} + +const float CarPhysics::ACCELERATION{20.f}; +const float CarPhysics::BRAKE_FORCE{5.f}; +const float CarPhysics::UNDERSTEER_SPEED_MUL{0.f}; +const float CarPhysics::OVERSTEER_SPEED_MUL{0.f}; +} diff --git a/src/car_physics.hpp b/src/car_physics.hpp new file mode 100644 index 0000000..814c54e --- /dev/null +++ b/src/car_physics.hpp @@ -0,0 +1,19 @@ +#ifndef CAR_PHYSICS_HPP +#define CAR_PHYSICS_HPP + +namespace godot { +class CarPhysics : public RigidBody3D { + GDCLASS(CarPhysics, RigidBody3D); + static void _bind_methods(); +public: + virtual void _enter_tree() override; + virtual void _integrate_forces(PhysicsDirectBodyState3D *state) override; +private: + static const float ACCELERATION; + static const float BRAKE_FORCE; + static const float UNDERSTEER_SPEED_MUL; + static const float OVERSTEER_SPEED_MUL; +}; +} + +#endif // !CAR_PHYSICS_HPP