feat: player implements no message receiver

This commit is contained in:
Sara 2023-11-27 17:40:51 +01:00
parent b1cecfc0ae
commit 53af5fb66d
2 changed files with 6 additions and 1 deletions

View file

@ -35,6 +35,7 @@ Player* MakePlayer() {
.playerInput = playerinput_new(self, -1),
.moveInput = ZeroVector,
.attackInput = 0,
.animationTriggers = 0,
.facing = 1,
@ -48,7 +49,7 @@ Player* MakePlayer() {
.animationStateMachine = NULL,
};
self->rigidbody = rigidbody_make(Player_as_Transformable(self));
self->rigidbody = rigidbody_make(Player_as_PhysicsEntity(self));
self->physicsCollider = collider_new(Player_as_PhysicsEntity(self), shape_new((Vector[]){
MakeVector(-0.2, -0.065),
MakeVector( 0.2, -0.065),
@ -80,6 +81,7 @@ Player* SpawnPlayer(Vector location) {
}
void DestroyPlayer(Player* self) {
physics_world_remove_entity(Player_as_PhysicsEntity(self));
collider_destroy(self->physicsCollider);
rigidbody_destroy(self->rigidbody);

View file

@ -24,6 +24,7 @@ typedef struct Player {
Vector moveInput;
int attackInput;
size_t animationTriggers;
int facing;
@ -59,6 +60,8 @@ void PlayerOnOverlap(Player* self, Collider* other);
static long PlayerGetDepth(Player* self) { return -10-(int)(self->transform.position.y * 1000); }
impl_no_MessageReceiver_for(Player)
impl_Drop_for(Player,
DestroyPlayer
)