49 lines
999 B
C
49 lines
999 B
C
#pragma once
|
|
|
|
#include "../../ecs_entity.h"
|
|
|
|
#include "../../../input/control.h"
|
|
|
|
static const f32 COMPONENT_PHYSICS_FRICTION_DEFAULT = 1.0f;
|
|
static const vec3 COMPONENT_PHYSICS_VELOCITY_MAX_DEFAULT = {1000.0f, 1000.0f, 1000.0f};
|
|
|
|
typedef struct ComponentPhysics
|
|
{
|
|
Component component;
|
|
vec3 position;
|
|
vec3 velocity;
|
|
vec3 velocityMax;
|
|
f32 friction;
|
|
bool isMoving;
|
|
} ComponentPhysics;
|
|
|
|
void component_physics_tick(ComponentPhysics* self, ECS* ecs);
|
|
void component_physics_next_position_get(ComponentPhysics* self, ECS* ecs, vec2 position);
|
|
f32 component_physics_next_position_distance_get(ComponentPhysics* self, ECS* ecs);
|
|
|
|
void component_physics_init
|
|
(
|
|
ComponentPhysics* self,
|
|
ECS* ecs,
|
|
const vec3 position,
|
|
const vec3 velocityMax,
|
|
f32 friction
|
|
);
|
|
|
|
static const ComponentInfo COMPONENT_PHYSICS_INFO =
|
|
{
|
|
.system =
|
|
{
|
|
.functions =
|
|
{
|
|
NULL,
|
|
NULL,
|
|
(ECSFunction)component_physics_tick,
|
|
NULL,
|
|
NULL
|
|
}
|
|
},
|
|
.type = COMPONENT_PHYSICS,
|
|
.size = sizeof(ComponentPhysics)
|
|
};
|