aboutsummaryrefslogtreecommitdiffstats
path: root/src/entity.c
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-10-25 23:18:08 +0000
committernathan <nathansmith@disroot.org>2025-10-25 23:18:08 +0000
commit32e795acb0c60a320b8449a3b7b6ee5fb5779c12 (patch)
tree62ea2eb3ccac8adba7fcdada36a63f25541913f5 /src/entity.c
parent233d6994bea031c0d22a77f5a8b7427a2b566e12 (diff)
downloadFindThings-32e795acb0c60a320b8449a3b7b6ee5fb5779c12.tar.gz
FindThings-32e795acb0c60a320b8449a3b7b6ee5fb5779c12.tar.bz2
FindThings-32e795acb0c60a320b8449a3b7b6ee5fb5779c12.zip
Switching to better entity system
Diffstat (limited to 'src/entity.c')
-rw-r--r--src/entity.c67
1 files changed, 18 insertions, 49 deletions
diff --git a/src/entity.c b/src/entity.c
index 3f988ad..caba91a 100644
--- a/src/entity.c
+++ b/src/entity.c
@@ -1,22 +1,15 @@
#include "entity.h"
#include "game.h"
-BoundingBox entityBoxFromScale(float scale, float width, float height)
-{
- Vector2 size = (Vector2){width / height * scale, scale};
- size = Vector2Scale(size, 0.5);
-
- return (BoundingBox){
- .min = (Vector3){-size.x, -size.y, -size.x},
- .max = (Vector3){size.x, size.y, size.x}
- };
-}
+const EntityEntry entityEntries[ENTITY_COUNT] = {
+};
Entity createEntity(EntityId id, Vector3 position)
{
Entity entity;
entity.id = id;
entity.state = ENTITY_DEFAULT_STATE;
+ entity.data = NULL;
// Bounding boxes.
switch (id)
@@ -84,8 +77,7 @@ Entity createEntity(EntityId id, Vector3 position)
.min = (Vector3){-SHOPKEEPER_WIDTH, -SHOPKEEPER_HEIGHT,
-SHOPKEEPER_THICKNESS},
.max = (Vector3){SHOPKEEPER_WIDTH, SHOPKEEPER_HEIGHT,
- SHOPKEEPER_THICKNESS}
-
+ SHOPKEEPER_THICKNESS}
};
break;
@@ -98,41 +90,6 @@ Entity createEntity(EntityId id, Vector3 position)
return entity;
}
-void updateSamantha(Entity* entity, Game* game)
-{
- // silly tv static effect.
- game->assets.models[SAMANTHA_MODEL].materials[0]
- .maps[MATERIAL_MAP_DIFFUSE].texture =
- game->assets.textures[
- SAMANTHA_1_TEXTURE + ((int)(GetTime() * SAMANTHA_STATIC_SPEED) %
- SAMANTHA_STATIC_FRAMES)];
-
- DrawModel(game->assets.models[SAMANTHA_MODEL], entity->position, 1.0,
- WHITE);
-}
-
-void updateTrashcan(Entity* entity, Game* game)
-{
- int frame = (int)(GetTime() * TRASHCAN_ANIMATION_SPEED) % TRASHCAN_FRAMES;
-
- Rectangle rect = (Rectangle){
- .x = frame * TRASHCAN_WIDTH,
- .y = 0.0,
- .width = TRASHCAN_WIDTH,
- .height = TRASHCAN_HEIGHT
- };
-
- DrawBillboardRec(
- game->player.camera,
- game->assets.textures[TRASHCAN_TEXTURE],
- rect,
- entity->position,
- (Vector2){TRASHCAN_SCALE
- * (TRASHCAN_WIDTH / TRASHCAN_HEIGHT),
- TRASHCAN_SCALE},
- WHITE);
-}
-
void updateEntity(Entity* entity, Game* game)
{
//DrawBoundingBox(entity->box, RED);
@@ -165,7 +122,7 @@ void updateEntity(Entity* entity, Game* game)
(Vector2){POND_SIZE * 2.5, POND_SIZE * 2.5}, BLUE);
break;
case SAMANTHA:
- updateSamantha(entity, game);
+ //updateSamantha(entity, game);
break;
case SAMANTHAS_SPOT:
DrawModel(game->world.samanthasSpotFloor,
@@ -174,7 +131,7 @@ void updateEntity(Entity* entity, Game* game)
1.0, WHITE);
break;
case TRASHCAN:
- updateTrashcan(entity, game);
+ //updateTrashcan(entity, game);
break;
case TRASH:
DrawBillboard(game->player.camera, game->assets.textures[TRASH_TEXTURE],
@@ -253,3 +210,15 @@ InteractionCommand interactWithEntity(Entity* entity, Game* game,
return INTERACTION_END;
}
+
+BoundingBox entityBoxFromScale(float scale, float width, float height)
+{
+ Vector2 size = (Vector2){width / height * scale, scale};
+ size = Vector2Scale(size, 0.5);
+
+ return (BoundingBox){
+ .min = (Vector3){-size.x, -size.y, -size.x},
+ .max = (Vector3){size.x, size.y, size.x}
+ };
+}
+