feat: colliders now have a separate 'mask' and 'layers'
The mask decides the layers a collider collides with
This commit is contained in:
parent
96acaa0a24
commit
2dec4da52c
7 changed files with 39 additions and 11 deletions
|
|
@ -59,13 +59,14 @@ Enemy* MakeEnemy() {
|
|||
};
|
||||
|
||||
self->rigidbody = rigidbody_make(Enemy_as_PhysicsEntity(self));
|
||||
self->collider = collider_new(Enemy_as_PhysicsEntity(self), shape_new_square(MakeVector(0.2f, 0.05f)), 0, PHYSICS_LAYER_DEFAULT);
|
||||
self->collider = collider_new(Enemy_as_PhysicsEntity(self), shape_new_square(MakeVector(0.2f, 0.05f)), 0,
|
||||
PHYSICS_LAYER_DEFAULT, PHYSICS_LAYER_DEFAULT);
|
||||
self->collider = collider_new(Enemy_as_PhysicsEntity(self), shape_new((Vector[]){
|
||||
MakeVector(-0.2f, -0.95f),
|
||||
MakeVector( 0.2f, -0.95f),
|
||||
MakeVector( 0.2f, 0.0f),
|
||||
MakeVector(-0.2f, 0.0f),
|
||||
}, 4), 1, PHYSICS_LAYER_COMBAT);
|
||||
}, 4), 1, PHYSICS_LAYER_COMBAT, 0x0);
|
||||
PhysicsEntity pe = Enemy_as_PhysicsEntity(self);
|
||||
LOG_INFO("enemy instantiated mirroring as: %s", pe.mirror->get_typestring(pe.data));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef FIGHT_LAYERS_H
|
||||
#define FIGHT_LAYERS_H
|
||||
|
||||
#define PHYSICS_LAYER_COMBAT 0x2
|
||||
#define PHYSICS_LAYER_CHARACTERS 0x2
|
||||
#define PHYSICS_LAYER_COMBAT 0x3
|
||||
|
||||
#endif // !FIGHT_LAYERS_H
|
||||
#endif // !FIGHT_LAYERS_H
|
||||
|
|
|
|||
|
|
@ -95,13 +95,13 @@ Player* MakePlayer() {
|
|||
MakeVector( 0.2f, -0.065f),
|
||||
MakeVector( 0.2f, 0.065f),
|
||||
MakeVector(-0.2f, 0.065f)
|
||||
}, 4), 0, PHYSICS_LAYER_DEFAULT);
|
||||
}, 4), 0, PHYSICS_LAYER_CHARACTERS, PHYSICS_LAYER_DEFAULT);
|
||||
self->hitbox = collider_new(Player_as_PhysicsEntity(self), shape_new((Vector[]){
|
||||
MakeVector(-0.2f, -0.95f),
|
||||
MakeVector( 0.2f, -0.95f),
|
||||
MakeVector( 0.2f, 0.00f),
|
||||
MakeVector(-0.2f, 0.00f)
|
||||
}, 3), 1, PHYSICS_LAYER_COMBAT);
|
||||
}, 3), 1, PHYSICS_LAYER_COMBAT, 0x0);
|
||||
|
||||
sprite_set_origin(self->sprite, MakeVector(0.45f, 0.925f));
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Prop* MakeProp(Sprite* sprite, Shape* shape) {
|
|||
.collisionShape = NULL
|
||||
};
|
||||
self->rigidbody = rigidbody_make(Prop_as_PhysicsEntity(self));
|
||||
self->collisionShape = collider_new(Prop_as_PhysicsEntity(self), shape, 0, PHYSICS_LAYER_DEFAULT);
|
||||
self->collisionShape = collider_new(Prop_as_PhysicsEntity(self), shape, 0, PHYSICS_LAYER_DEFAULT, PHYSICS_LAYER_DEFAULT);
|
||||
rigidbody_set_static(self->rigidbody, 1);
|
||||
sprite_set_origin(self->sprite, MakeVector(0.5f, 1.0f));
|
||||
return self;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue