diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-07 00:57:19 -0600 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-07 00:57:19 -0600 |
commit | 028cf5d33d99274deea9567159a4eb07c13ef85c (patch) | |
tree | b2d9f0ae8fb640fdbe1a41114c7c8314f9223103 /src/entity.h | |
parent | 416a5cbab21c480ae9e85b07fd9424452cbcb611 (diff) |
This fucker is flying
Diffstat (limited to 'src/entity.h')
-rw-r--r-- | src/entity.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/entity.h b/src/entity.h new file mode 100644 index 0000000..0f9ec3d --- /dev/null +++ b/src/entity.h @@ -0,0 +1,70 @@ +#include "gameCommon.h" + +#ifndef ENTITY_H +#define ENTITY_H + +enum { + ENTITY_NONE = -1, + ENTITY_ANTIFA, + ENTITY_SOLDATO, + ENTITY_CAPORALE, + ENTITY_SERGENTE, + ENTITY_MARESCIALLO, + ENTITY_GENERALE, + ENTITY_MUSSOLINI +}; + +#define ENTITY_TYPE_COUNT 7 + +typedef int8_t EntityType; +typedef int16_t EntityId; // Id in world. + +// Callbacks. +typedef void (*EntityUpdateCb)(Game * game, Entity * entity, EntityId id); +typedef void (*EntityDrawCb)(Game * game, Entity * entity, EntityId id); + +// This fucker is a entity. +typedef struct Entity { + EntityType type; + Model model; + + Vector3 position; + Vector3 velocity; + + float angularVelocity; + Vector3 rotationAxis; + + Quaternion rotation; + + EntityUpdateCb updateCb; + EntityDrawCb drawCb; + + // Used for whatever. + void * data; +} Entity; + +typedef void (*EntityInitCb)(Entity * entity); +typedef void (*EntityCloseCb)(Entity * entity); + +// Info for each entity type. +typedef struct EntityTypeInfo { + EntityInitCb initCb; + EntityCloseCb closeCb; + EntityUpdateCb updateCb; + EntityDrawCb drawCb; +} EntityTypeInfo; + +const extern EntityTypeInfo entityTypeInfo[ENTITY_TYPE_COUNT]; + +// Do I need a fucking comment? +Entity createEntity(EntityType type); +void closeEntity(Entity * entity); + +// Helper functions for updating and drawing. +void entityDraw(Entity * entity); +void entityUpdatePosition(Entity * entity); +void entityUpdateRotation(Entity * entity); + +void entityJoystickControl(Entity * entity, Vector3 stick, float speed); + +#endif |