summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authortheo3 <arisstephenson2@gmail.com>2023-12-31 21:24:07 -0800
committertheo3 <arisstephenson2@gmail.com>2023-12-31 21:26:12 -0800
commitdcc596ed8763efd9f71ce9a669cb67a1849d7c2b (patch)
tree108145ce0ee3172e48ac6529d9d49da53e9719b9 /include
parent48fdf9d8277d2bd2e071cb30fc6284c58645e343 (diff)
define collisions
Diffstat (limited to 'include')
-rw-r--r--include/definitions.h4
-rw-r--r--include/entity.h40
-rw-r--r--include/player.h2
3 files changed, 39 insertions, 7 deletions
diff --git a/include/definitions.h b/include/definitions.h
index 7764f76f..088635db 100644
--- a/include/definitions.h
+++ b/include/definitions.h
@@ -22,7 +22,7 @@ typedef struct EnemyDefinition {
u8 health;
s16 speed;
u8 damageType;
- u8 flags2;
+ u8 collisionMask;
} EnemyDefinition;
typedef struct ProjectileDefinition {
@@ -43,7 +43,7 @@ typedef struct ProjectileDefinition {
u8 field0x40;
s16 speed;
u8 damageType;
- u8 flags2;
+ u8 collisionMask;
} ProjectileDefinition;
// Sprite data definition for objects and npcs
diff --git a/include/entity.h b/include/entity.h
index 8a66283c..455761c0 100644
--- a/include/entity.h
+++ b/include/entity.h
@@ -79,7 +79,39 @@ typedef enum {
DirectionNorthWest = 0x1c, /**< North West. */
} Direction;
-#define CONTACT_TAKE_DAMAGE 0x80
+/** Collision layer flags. */
+typedef enum {
+ COL_LAYER_NONE = 0x0,
+ COL_LAYER_BOTTOM = 0x1,
+ COL_LAYER_TOP = 0x2,
+ COL_LAYER_BOTH = 0x3
+} CollisionLayer;
+
+/**
+ * Collision class flags.
+ * An Entity's collision class is determined by the first 3 bits of #Entity::collisionFlags.
+ * What classes an Entity collides with is determined by the bitfield #Entity::collisionMask.
+*/
+typedef enum {
+ COL_CLASS_NONE = 0x0,
+ COL_CLASS_PLAYER = 0x1,
+ COL_CLASS_ITEM = 0x2,
+ COL_CLASS_FLAMMABLE = 0x3,
+ COL_CLASS_4 = 0x4,
+ COL_CLASS_5 = 0x5,
+ COL_CLASS_6 = 0x6,
+ COL_CLASS_PACCI_OBJ = 0x7,
+} CollisionClass;
+
+/** Collision flags. */
+typedef enum {
+ COL_FLAG_3D = 0x10,
+ COL_FLAG_SOLID = 0x20,
+ COL_FLAG_REFLECT = 0x80,
+} CollisionFlags;
+
+#define COLLISION_MASK(layer) (1 << (layer))
+#define CONTACT_NOW 0x80
typedef struct {
void* entity1;
@@ -194,11 +226,11 @@ typedef struct Entity_ {
/*0x2c*/ union SplitWord x; /**< X position, fixed point Q16.16. */
/*0x30*/ union SplitWord y; /**< Y position, fixed point Q16.16. */
/*0x34*/ union SplitWord z; /**< Z position, fixed point Q16.16. */
- /*0x38*/ u8 collisionLayer; /**< Collision layer. */
+ /*0x38*/ u8 collisionLayer; /**< @see CollisionLayer. */
/*0x39*/ s8 interactType;
/*0x3a*/ u8 gustJarState; /**< 4: grabbed by GustJar */
- /*0x3b*/ u8 flags2; /**< Debug visualization related? */
- /*0x3c*/ u8 collisionFlags; /**< Controls collision modes. */
+ /*0x3b*/ u8 collisionMask; /**< Bitfield. @see CollisionClass */
+ /*0x3c*/ u8 collisionFlags; /**< @see CollisionFlags, @see CollisionClass */
/*0x3d*/ s8 iframes; /**< Invulnerability frames. */
/*0x3e*/ u8 knockbackDirection; /**< Direction of knockback. */
/*0x3f*/ u8 hitType; /**< Behavior as a collision sender. */
diff --git a/include/player.h b/include/player.h
index 0f0aa027..e344d0af 100644
--- a/include/player.h
+++ b/include/player.h
@@ -511,7 +511,7 @@ typedef struct {
/*0x39*/ u8 field_0x39;
/*0x3a*/ u8 field_0x3a;
/*0x3b*/ u8 field_0x3b;
- /*0x3c*/ u8 field_0x3c;
+ /*0x3c*/ u8 killed; /**< Non-zero if player is dead */
/*0x3d*/ u8 moleMittsState;
/*0x3e*/ u8 swordDamage : 2;
/* */ u8 filler14 : 6;