feat: created CarPhysics class

This commit is contained in:
Sara 2024-05-16 08:43:45 +02:00
parent 82b258c58f
commit ea2e6fc13c
2 changed files with 35 additions and 0 deletions

16
src/car_physics.cpp Normal file
View file

@ -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};
}

19
src/car_physics.hpp Normal file
View file

@ -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