aboutsummaryrefslogtreecommitdiff
path: root/src/entities
diff options
context:
space:
mode:
authornathansmithsmith <thenathansmithsmith@gmail.com>2023-07-21 13:48:02 -0600
committernathansmithsmith <thenathansmithsmith@gmail.com>2023-07-21 13:48:02 -0600
commita408b352f13df546b2262ca01cf162b60891cdae (patch)
tree6a7f7053efbf01c65cb82df4478721c3a818f07a /src/entities
parentd4b40dcf7589bef2bbd0b6b940ee992da9db2343 (diff)
Sonic fast collision
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/antifaShip.c9
-rw-r--r--src/entities/soldato.c9
2 files changed, 18 insertions, 0 deletions
diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c
index 6fe4b66..94fc8c8 100644
--- a/src/entities/antifaShip.c
+++ b/src/entities/antifaShip.c
@@ -5,6 +5,8 @@
void initAntifaShip(Entity * entity, Game * game) {
entity->model = &game->assets.models[ANTIFA_SHIP_ASSET];
+ entity->collisionModel = entityCreateCollisionModel(*entity->model);
+ entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model);
setEntityRadius(entity);
// Acceleration stuff.
@@ -31,6 +33,9 @@ void initAntifaShip(Entity * entity, Game * game) {
void closeAntifaShip(Entity * entity) {
if (entity->data != NULL)
KF_FREE(entity->data);
+
+ entityFreeCollisionModel(entity->collisionModel);
+ entityFreeCollisionModel(entity->transformedCollisionModel);
}
void controlAntifaShipJoystick(Game * game, Entity * entity) {
@@ -102,6 +107,8 @@ void controlAntifaShipKeyboardAndMouse(Game * game, Entity * entity) {
}
void updateAntifaShip(Game * game, Entity * entity) {
+ entityUpdateLastValues(entity);
+
switch (game->settings.controlMode) {
case JOYSTICK_CONTROL:
controlAntifaShipJoystick(game, entity);
@@ -112,6 +119,8 @@ void updateAntifaShip(Game * game, Entity * entity) {
default:
break;
}
+
+ entityCheckTransformedCollisionModel(entity);
}
void drawAntifaShip(Game * game, Entity * entity) {
diff --git a/src/entities/soldato.c b/src/entities/soldato.c
index 74544aa..2cc0e07 100644
--- a/src/entities/soldato.c
+++ b/src/entities/soldato.c
@@ -3,6 +3,8 @@
void initSoldato(Entity * entity, Game * game) {
entity->model = &game->assets.models[SOLDATO_ASSET];
+ entity->collisionModel = entityCreateCollisionModel(*entity->model);
+ entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model);
setEntityRadius(entity);
// Acceleration.
@@ -46,9 +48,14 @@ void initSoldato(Entity * entity, Game * game) {
void closeSoldato(Entity * entity) {
if (entity->data != NULL)
KF_FREE(entity->data);
+
+ entityFreeCollisionModel(entity->collisionModel);
+ entityFreeCollisionModel(entity->transformedCollisionModel);
}
void updateSoldato(Game * game, Entity * entity) {
+ entityUpdateLastValues(entity);
+
Entity * player = getEntityFromWorld(game->world, 0);
Soldato * data = (Soldato*)entity->data;
@@ -57,6 +64,8 @@ void updateSoldato(Game * game, Entity * entity) {
player->position,
&data->flyToPoint
);
+
+ entityCheckTransformedCollisionModel(entity);
}
void drawSoldato(Game * game, Entity * entity) {