aboutsummaryrefslogtreecommitdiff
path: root/src/phys/body.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/phys/body.odin')
-rw-r--r--src/phys/body.odin30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/phys/body.odin b/src/phys/body.odin
index 0fe6c51..d568186 100644
--- a/src/phys/body.odin
+++ b/src/phys/body.odin
@@ -7,15 +7,15 @@ Rect :: struct {
size: Vec2,
}
-Layer :: enum(u16) {
+Layer :: enum (u16) {
DEFAULT,
- HARD, // hard collisions; don't let bodies intersect at all
- SOFT, // soft collisions; push away other bodies with a force
- ENEMY, // enemy hitboxes
+ HARD, // hard collisions; don't let bodies intersect at all
+ SOFT, // soft collisions; push away other bodies with a force
+ ENEMY, // enemy hitboxes
PLAYER, // player hitboxes
}
-Collision_Type :: enum(u8) {
+Collision_Type :: enum (u8) {
UP,
DOWN,
RIGHT,
@@ -31,20 +31,23 @@ Body :: struct {
active: bool,
pos: Vec2,
vel: Vec2,
- collisions: bit_set[Collision_Type; u8],
- layers: bit_set[Layer; u16],
- mask: bit_set[Layer; u16],
+ collisions: bit_set[Collision_Type;u8],
+ layers: bit_set[Layer;u16],
+ mask: bit_set[Layer;u16],
}
make_body :: proc(
rect: Rect,
- layers := bit_set[Layer; u16]{.DEFAULT},
- mask := bit_set[Layer; u16]{.DEFAULT},
-) -> (Body_Handle, ^Body) {
+ layers := bit_set[Layer;u16]{.DEFAULT},
+ mask := bit_set[Layer;u16]{.DEFAULT},
+) -> (
+ Body_Handle,
+ ^Body,
+) {
b := Body {
- rect = rect,
+ rect = rect,
layers = layers,
- mask = mask,
+ mask = mask,
active = true,
}
return add_body(b)
@@ -61,4 +64,3 @@ aabb_vert :: proc(a: Rect, b: Rect) -> bool {
aabb :: proc(a: Rect, b: Rect) -> bool {
return aabb_hori(a, b) && aabb_vert(a, b)
}
-