From a90e1987de75cfecc2693952625af8cce507ae95 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Fri, 7 Jul 2023 02:24:09 -0600 Subject: Added acceleration --- src/entity.h | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/entity.h') diff --git a/src/entity.h b/src/entity.h index 0f9ec3d..7d27258 100644 --- a/src/entity.h +++ b/src/entity.h @@ -1,4 +1,5 @@ #include "gameCommon.h" +#include "util.h" #ifndef ENTITY_H #define ENTITY_H @@ -23,19 +24,40 @@ typedef int16_t EntityId; // Id in world. typedef void (*EntityUpdateCb)(Game * game, Entity * entity, EntityId id); typedef void (*EntityDrawCb)(Game * game, Entity * entity, EntityId id); +// Acceleration indeed hehehe. +typedef struct EntityAcceleration { + Vector3 rotationUp; + Vector3 rotationDown; + float speedUp; + float speedDown; +} EntityAcceleration; + +float accelerateValue(float value, float lastValue, float up, float down); +Vector3 accelerateVector3(Vector3 value, Vector3 lastValue, Vector3 up, Vector3 down); + +typedef struct EntityVelocity { + Vector3 velocity; + AxisAngle angularVelocity; + Vector3 stick; // Pilot control stick. + float speed; // Somewhat general use (: +} EntityVelocity; + +EntityVelocity entityVelocityIdentity(); + // This fucker is a entity. typedef struct Entity { EntityType type; Model model; Vector3 position; - Vector3 velocity; - - float angularVelocity; - Vector3 rotationAxis; - Quaternion rotation; + EntityVelocity velocity; + EntityVelocity lastVelocity; + + bool useAcceleration; + EntityAcceleration acceleration; + EntityUpdateCb updateCb; EntityDrawCb drawCb; -- cgit v1.2.3