aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile2
-rw-r--r--src/entities/bush.c12
-rw-r--r--src/entities/bush.h13
-rw-r--r--src/entities/flower.c12
-rw-r--r--src/entities/flower.h13
-rw-r--r--src/entities/john.c16
-rw-r--r--src/entities/john.h12
-rw-r--r--src/entities/medicalTrash.c14
-rw-r--r--src/entities/medicalTrash.h14
-rw-r--r--src/entities/oldMint.c12
-rw-r--r--src/entities/oldMint.h13
-rw-r--r--src/entities/pond.c15
-rw-r--r--src/entities/pond.h13
-rw-r--r--src/entities/ron.c16
-rw-r--r--src/entities/ron.h12
-rw-r--r--src/entities/samantha.c21
-rw-r--r--src/entities/samantha.h16
-rw-r--r--src/entities/samanthasSpot.c19
-rw-r--r--src/entities/samanthasSpot.h13
-rw-r--r--src/entities/shopKeeper.h8
-rw-r--r--src/entities/stickyNickel.c13
-rw-r--r--src/entities/stickyNickel.h13
-rw-r--r--src/entities/trash.c12
-rw-r--r--src/entities/trash.h14
-rw-r--r--src/entities/trashcan.c28
-rw-r--r--src/entities/trashcan.h16
-rw-r--r--src/entities/tree.c12
-rw-r--r--src/entities/tree.h13
-rw-r--r--src/entities/utilityPole.c11
-rw-r--r--src/entities/utilityPole.h12
-rw-r--r--src/entity.c67
-rw-r--r--src/entity.h25
32 files changed, 448 insertions, 54 deletions
diff --git a/src/Makefile b/src/Makefile
index 5088644..137e40b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,4 +1,4 @@
-CFLAGS = -I../include -std=c99
+CFLAGS = -I../include -I./ -I./entities -std=c99
LDFLAGS = -lm -lraylib
TARGET = FindThings
diff --git a/src/entities/bush.c b/src/entities/bush.c
new file mode 100644
index 0000000..884ffef
--- /dev/null
+++ b/src/entities/bush.c
@@ -0,0 +1,12 @@
+#include "bush.h"
+
+void initBush(Entity* entity)
+{
+ entity->box = entityBoxFromScale(1.0, BUSH_WIDTH, BUSH_HEIGHT);
+}
+
+void updateBush(Entity* entity, Game* game)
+{
+ DrawBillboard(game->player.camera, game->assets.textures[BUSH_TEXTURE],
+ entity->position, 1.0, WHITE);
+}
diff --git a/src/entities/bush.h b/src/entities/bush.h
new file mode 100644
index 0000000..70ac282
--- /dev/null
+++ b/src/entities/bush.h
@@ -0,0 +1,13 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef BUSH_H
+#define BUSH_H
+
+#define BUSH_WIDTH 87.0
+#define BUSH_HEIGHT 62.0
+
+void initBush(Entity* entity);
+void updateBush(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/flower.c b/src/entities/flower.c
new file mode 100644
index 0000000..00f27fc
--- /dev/null
+++ b/src/entities/flower.c
@@ -0,0 +1,12 @@
+#include "flower.h"
+
+void initFlower(Entity* entity)
+{
+ entity->box = entityBoxFromScale(1.0, FLOWER_WIDTH, FLOWER_HEIGHT);
+}
+
+void updateFlower(Entity* entity, Game* game)
+{
+ DrawBillboard(game->player.camera, game->assets.textures[FLOWER_TEXTURE],
+ entity->position, 1.0, WHITE);
+}
diff --git a/src/entities/flower.h b/src/entities/flower.h
new file mode 100644
index 0000000..de33197
--- /dev/null
+++ b/src/entities/flower.h
@@ -0,0 +1,13 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef FLOWER_H
+#define FLOWER_H
+
+#define FLOWER_WIDTH 32.0
+#define FLOWER_HEIGHT 54.0
+
+void initFlower(Entity* entity);
+void updateFlower(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/john.c b/src/entities/john.c
new file mode 100644
index 0000000..94f2cae
--- /dev/null
+++ b/src/entities/john.c
@@ -0,0 +1,16 @@
+#include "john.h"
+
+void initJohn(Entity* entity)
+{
+ entity->box = (BoundingBox){
+ .min = (Vector3){-SHOPKEEPER_WIDTH, -SHOPKEEPER_HEIGHT,
+ -SHOPKEEPER_THICKNESS},
+ .max = (Vector3){SHOPKEEPER_WIDTH, SHOPKEEPER_HEIGHT,
+ SHOPKEEPER_THICKNESS}
+ };
+}
+
+void updateJohn(Entity* entity, Game* game)
+{
+ DrawModel(game->assets.models[JOHN_MODEL], entity->position, 1.0, WHITE);
+}
diff --git a/src/entities/john.h b/src/entities/john.h
new file mode 100644
index 0000000..e2c1b11
--- /dev/null
+++ b/src/entities/john.h
@@ -0,0 +1,12 @@
+#include "game.h"
+#include "entity.h"
+#include "shopKeeper.h"
+
+#ifndef JOHN_H
+#define JOHN_H
+
+void initJohn(Entity* entity);
+void updateJohn(Entity* entity, Game* game);
+
+#endif
+
diff --git a/src/entities/medicalTrash.c b/src/entities/medicalTrash.c
new file mode 100644
index 0000000..4c4f9f3
--- /dev/null
+++ b/src/entities/medicalTrash.c
@@ -0,0 +1,14 @@
+#include "medicalTrash.h"
+
+void initMedicalTrash(Entity* entity)
+{
+ entity->box = entityBoxFromScale(MEDICAL_TRASH_SCALE, MEDICAL_TRASH_WIDTH,
+ MEDICAL_TRASH_HEIGHT);
+}
+
+void updateMedicalTrash(Entity* entity, Game* game)
+{
+ DrawBillboard(game->player.camera,
+ game->assets.textures[MEDICAL_TRASH_TEXTURE],
+ entity->position, MEDICAL_TRASH_SCALE, WHITE);
+}
diff --git a/src/entities/medicalTrash.h b/src/entities/medicalTrash.h
new file mode 100644
index 0000000..92c5df8
--- /dev/null
+++ b/src/entities/medicalTrash.h
@@ -0,0 +1,14 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef MEDICAL_TRASH_H
+#define MEDICAL_TRASH_H
+
+#define MEDICAL_TRASH_SCALE 2.0
+#define MEDICAL_TRASH_WIDTH 200.0
+#define MEDICAL_TRASH_HEIGHT 132.0
+
+void initMedicalTrash(Entity* entity);
+void updateMedicalTrash(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/oldMint.c b/src/entities/oldMint.c
new file mode 100644
index 0000000..17c751e
--- /dev/null
+++ b/src/entities/oldMint.c
@@ -0,0 +1,12 @@
+#include "oldMint.h"
+
+void initOldMint(Entity* entity)
+{
+ entity->box = entityBoxFromScale(1.0, OLD_MINT_WIDTH, OLD_MINT_HEIGHT);
+}
+
+void updateOldMint(Entity* entity, Game* game)
+{
+ DrawBillboard(game->player.camera, game->assets.textures[MINT_TEXTURE],
+ entity->position, 1.0, WHITE);
+}
diff --git a/src/entities/oldMint.h b/src/entities/oldMint.h
new file mode 100644
index 0000000..433b4a6
--- /dev/null
+++ b/src/entities/oldMint.h
@@ -0,0 +1,13 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef OLD_MINT_H
+#define OLD_MINT_H
+
+#define OLD_MINT_WIDTH 32.0
+#define OLD_MINT_HEIGHT 32.0
+
+void initOldMint(Entity* entity);
+void updateOldMint(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/pond.c b/src/entities/pond.c
new file mode 100644
index 0000000..a1cda5d
--- /dev/null
+++ b/src/entities/pond.c
@@ -0,0 +1,15 @@
+#include "pond.h"
+
+void initPond(Entity* entity)
+{
+ entity->box = (BoundingBox){
+ .min = (Vector3){-POND_SIZE, -POND_HEIGHT, -POND_SIZE},
+ .max = (Vector3){POND_SIZE, POND_HEIGHT, POND_SIZE}
+ };
+}
+
+void updatePond(Entity* entity, Game* game)
+{
+ DrawPlane(Vector3Add(entity->position, (Vector3){0.0, POND_HEIGHT, 0.0}),
+ (Vector2){POND_SIZE * 2.5, POND_SIZE * 2.5}, BLUE);
+}
diff --git a/src/entities/pond.h b/src/entities/pond.h
new file mode 100644
index 0000000..c041eb1
--- /dev/null
+++ b/src/entities/pond.h
@@ -0,0 +1,13 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef POND_H
+#define POND_H
+
+#define POND_SIZE 250.0
+#define POND_HEIGHT 15.0
+
+void initPond(Entity* entity);
+void updatePond(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/ron.c b/src/entities/ron.c
new file mode 100644
index 0000000..bd32e6a
--- /dev/null
+++ b/src/entities/ron.c
@@ -0,0 +1,16 @@
+#include "ron.h"
+
+void initRon(Entity* entity)
+{
+ entity->box = (BoundingBox){
+ .min = (Vector3){-SHOPKEEPER_WIDTH, -SHOPKEEPER_HEIGHT,
+ -SHOPKEEPER_THICKNESS},
+ .max = (Vector3){SHOPKEEPER_WIDTH, SHOPKEEPER_HEIGHT,
+ SHOPKEEPER_THICKNESS}
+ };
+}
+
+void updateRon(Entity* entity, Game* game)
+{
+ DrawModel(game->assets.models[RON_MODEL], entity->position, 1.0, WHITE);
+}
diff --git a/src/entities/ron.h b/src/entities/ron.h
new file mode 100644
index 0000000..10858c1
--- /dev/null
+++ b/src/entities/ron.h
@@ -0,0 +1,12 @@
+#include "game.h"
+#include "entity.h"
+#include "shopKeeper.h"
+
+#ifndef RON_H
+#define RON_H
+
+void initRon(Entity* entity);
+void updateRon(Entity* entity, Game* game);
+
+#endif
+
diff --git a/src/entities/samantha.c b/src/entities/samantha.c
new file mode 100644
index 0000000..a78b075
--- /dev/null
+++ b/src/entities/samantha.c
@@ -0,0 +1,21 @@
+#include "samantha.h"
+
+void initSamantha(Entity* entity)
+{
+ entity->box = (BoundingBox){
+ .min = (Vector3){-SAMANTHA_WIDTH, -SAMANTHA_HEIGHT, -SAMANTHA_THICKNESS},
+ .max = (Vector3){SAMANTHA_WIDTH, SAMANTHA_HEIGHT, SAMANTHA_THICKNESS}
+ };
+}
+
+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);
+}
diff --git a/src/entities/samantha.h b/src/entities/samantha.h
new file mode 100644
index 0000000..360c9f0
--- /dev/null
+++ b/src/entities/samantha.h
@@ -0,0 +1,16 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef SAMANTHA_H
+#define SAMANTHA_H
+
+#define SAMANTHA_WIDTH (2.65966 / 2.0)
+#define SAMANTHA_HEIGHT (3.21054 / 2.0)
+#define SAMANTHA_THICKNESS (1.46845 / 2.0)
+#define SAMANTHA_STATIC_SPEED 24
+#define SAMANTHA_STATIC_FRAMES 4
+
+void initSamantha(Entity* entity);
+void updateSamantha(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/samanthasSpot.c b/src/entities/samanthasSpot.c
new file mode 100644
index 0000000..0205e46
--- /dev/null
+++ b/src/entities/samanthasSpot.c
@@ -0,0 +1,19 @@
+#include "samanthasSpot.h"
+
+void initSamanthasSpot(Entity* entity)
+{
+ entity->box = (BoundingBox){
+ .min = (Vector3){-SAMANTHAS_SPOT_SIZE, -SAMANTHAS_SPOT_HEIGHT,
+ -SAMANTHAS_SPOT_SIZE},
+ .max = (Vector3){SAMANTHAS_SPOT_SIZE, SAMANTHAS_SPOT_HEIGHT,
+ SAMANTHAS_SPOT_SIZE},
+ };
+}
+
+void updateSamanthasSpot(Entity* entity, Game* game)
+{
+ DrawModel(game->world.samanthasSpotFloor,
+ Vector3Add(entity->position,
+ (Vector3){0.0, -SAMANTHAS_SPOT_HEIGHT + 0.01, 0.0}),
+ 1.0, WHITE);
+}
diff --git a/src/entities/samanthasSpot.h b/src/entities/samanthasSpot.h
new file mode 100644
index 0000000..21413ac
--- /dev/null
+++ b/src/entities/samanthasSpot.h
@@ -0,0 +1,13 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef SAMANTHAS_SPOT_H
+#define SAMANTHAS_SPOT_H
+
+#define SAMANTHAS_SPOT_SIZE 10
+#define SAMANTHAS_SPOT_HEIGHT 5
+
+void initSamanthasSpot(Entity* entity);
+void updateSamanthasSpot(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/shopKeeper.h b/src/entities/shopKeeper.h
new file mode 100644
index 0000000..6441bed
--- /dev/null
+++ b/src/entities/shopKeeper.h
@@ -0,0 +1,8 @@
+#ifndef SHOP_KEEPER_H
+#define SHOP_KEEPER_H
+
+#define SHOPKEEPER_WIDTH (2.04211 / 2.0)
+#define SHOPKEEPER_HEIGHT (2.59521 / 2.0)
+#define SHOPKEEPER_THICKNESS (0.493349 / 2.0)
+
+#endif
diff --git a/src/entities/stickyNickel.c b/src/entities/stickyNickel.c
new file mode 100644
index 0000000..94755c5
--- /dev/null
+++ b/src/entities/stickyNickel.c
@@ -0,0 +1,13 @@
+#include "stickyNickel.h"
+
+void initStickyNickel(Entity* entity)
+{
+ entity->box = entityBoxFromScale(1.0, STICKY_NICKEL_WIDTH,
+ STICKY_NICKEL_HEIGHT);
+}
+
+void updateStickyNickel(Entity* entity, Game* game)
+{
+ DrawBillboard(game->player.camera, game->assets.textures[NICKEL_TEXTURE],
+ entity->position, 1.0, WHITE);
+}
diff --git a/src/entities/stickyNickel.h b/src/entities/stickyNickel.h
new file mode 100644
index 0000000..b7c938e
--- /dev/null
+++ b/src/entities/stickyNickel.h
@@ -0,0 +1,13 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef STICKY_NICKEL_H
+#define STICKY_NICKEL_H
+
+#define STICKY_NICKEL_WIDTH 32.0
+#define STICKY_NICKEL_HEIGHT 32.0
+
+void initStickyNickel(Entity* entity);
+void updateStickyNickel(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/trash.c b/src/entities/trash.c
new file mode 100644
index 0000000..627276f
--- /dev/null
+++ b/src/entities/trash.c
@@ -0,0 +1,12 @@
+#include "trash.h"
+
+void initTrash(Entity* entity)
+{
+ entity->box = entityBoxFromScale(TRASH_SCALE, TRASH_WIDTH, TRASH_HEIGHT);
+}
+
+void updateTrash(Entity* entity, Game* game)
+{
+ DrawBillboard(game->player.camera, game->assets.textures[TRASH_TEXTURE],
+ entity->position, TRASH_SCALE, WHITE);
+}
diff --git a/src/entities/trash.h b/src/entities/trash.h
new file mode 100644
index 0000000..1505073
--- /dev/null
+++ b/src/entities/trash.h
@@ -0,0 +1,14 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef TRASH_H
+#define TRASH_H
+
+#define TRASH_SCALE 2.0
+#define TRASH_WIDTH 202.0
+#define TRASH_HEIGHT 122.0
+
+void initTrash(Entity* entity);
+void updateTrash(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/trashcan.c b/src/entities/trashcan.c
new file mode 100644
index 0000000..880bc4c
--- /dev/null
+++ b/src/entities/trashcan.c
@@ -0,0 +1,28 @@
+#include "trashcan.h"
+
+void initTrashcan(Entity* entity)
+{
+ entity->box = entityBoxFromScale(TRASHCAN_SCALE, TRASHCAN_WIDTH,
+ TRASHCAN_HEIGHT);
+}
+
+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);
+}
diff --git a/src/entities/trashcan.h b/src/entities/trashcan.h
new file mode 100644
index 0000000..62d9ae0
--- /dev/null
+++ b/src/entities/trashcan.h
@@ -0,0 +1,16 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef TRASHCAN_H
+#define TRASHCAN_H
+
+#define TRASHCAN_SCALE 2.0
+#define TRASHCAN_FRAMES 4
+#define TRASHCAN_ANIMATION_SPEED 6
+#define TRASHCAN_WIDTH 45.0
+#define TRASHCAN_HEIGHT 60.0
+
+void initTrashcan(Entity* entity);
+void updateTrashcan(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/tree.c b/src/entities/tree.c
new file mode 100644
index 0000000..7db5842
--- /dev/null
+++ b/src/entities/tree.c
@@ -0,0 +1,12 @@
+#include "tree.h"
+
+void initTree(Entity* entity)
+{
+ entity->box = entityBoxFromScale(1.0, TREE_WIDTH, TREE_HEIGHT);
+}
+
+void updateTree(Entity* entity, Game* game)
+{
+ DrawBillboard(game->player.camera, game->assets.textures[TREE_TEXTURE],
+ entity->position, 1.0, WHITE);
+}
diff --git a/src/entities/tree.h b/src/entities/tree.h
new file mode 100644
index 0000000..59b32ba
--- /dev/null
+++ b/src/entities/tree.h
@@ -0,0 +1,13 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef TREE_H
+#define TREE_H
+
+#define TREE_WIDTH 113.0
+#define TREE_HEIGHT 250.0
+
+void initTree(Entity* entity);
+void updateTree(Entity* entity, Game* game);
+
+#endif
diff --git a/src/entities/utilityPole.c b/src/entities/utilityPole.c
new file mode 100644
index 0000000..7f98d52
--- /dev/null
+++ b/src/entities/utilityPole.c
@@ -0,0 +1,11 @@
+#include "utilityPole.h"
+
+void initUtilityPole(Entity* entity)
+{
+ entity->box = (BoundingBox){
+ .min = (Vector3){-UTILITY_POLE_RADIUS, -UTILITY_POLE_HEIGHT,
+ -UTILITY_POLE_RADIUS},
+ .max = (Vector3){UTILITY_POLE_RADIUS, UTILITY_POLE_HEIGHT,
+ UTILITY_POLE_RADIUS},
+ };
+}
diff --git a/src/entities/utilityPole.h b/src/entities/utilityPole.h
new file mode 100644
index 0000000..0c107db
--- /dev/null
+++ b/src/entities/utilityPole.h
@@ -0,0 +1,12 @@
+#include "game.h"
+#include "entity.h"
+
+#ifndef UTILITY_POLE_H
+#define UTILITY_POLE_H
+
+#define UTILITY_POLE_HEIGHT 100.0
+#define UTILITY_POLE_RADIUS 3.0
+
+void initUtilityPole(Entity* entity);
+
+#endif
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}
+ };
+}
+
diff --git a/src/entity.h b/src/entity.h
index 9727e51..3170059 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -45,7 +45,13 @@
#define ENTITY_DEFAULT_STATE -1
typedef int8_t EntityId;
-typedef int8_t EntityState;
+typedef int16_t EntityState;
+
+typedef struct Entity Entity;
+typedef void (*InteractionCallback)(Entity* entity, Game* game);
+typedef void (*InitEntityCallback)(Entity* entity);
+typedef void (*UpdateEntityCallback)(Entity* entity, Game* game);
+typedef void (*CloseEntityCallback)(Entity* entity);
enum {
ENTITY_NONE = -1,
@@ -78,20 +84,29 @@ typedef enum {
SELECTION_LEAVE
} Selection;
-typedef struct {
+struct Entity {
EntityId id;
Vector3 position; // Shouldnt be changed directly.
BoundingBox box;
EntityState state;
-} Entity;
+ void* data;
+};
-typedef void (*InteractionCallback)(Entity* entity, Game* game);
+typedef struct {
+ InitEntityCallback initCallback;
+ UpdateEntityCallback updateCallback;
+ CloseEntityCallback closeCallback;
+ bool isPlace;
+ bool canBeSelected;
+} EntityEntry;
typedef struct {
char label[INTERACTION_LABEL_MAX];
InteractionCallback callback;
} InteractionMenuEntry;
+extern const EntityEntry entityEntries[ENTITY_COUNT];
+
Entity createEntity(EntityId id, Vector3 position);
void updateEntity(Entity* entity, Game* game);
void setEntityPosition(Entity* entity, Vector3 position);
@@ -101,4 +116,6 @@ bool entityCanBeSelected(EntityId id);
InteractionCommand interactWithEntity(Entity* entity, Game* game,
Selection selection);
+BoundingBox entityBoxFromScale(float scale, float width, float height);
+
#endif