#include "Prop.h" #include "debug.h" #include "game_world.h" #include "physics_world.h" Prop* MakeProp(Sprite* sprite, Shape* shape) { Prop* self = malloc(sizeof(Prop)); ASSERT_RETURN(self != NULL, NULL, "Failed to allocate space for Prop instance"); *self = (Prop) { .transform = IdentityTransform, .sprite = sprite, .rigidbody = NULL, .collisionShape = shape }; self->rigidbody = rigidbody_make(Prop_as_Transformable(self)); rigidbody_set_static(self->rigidbody, 1); sprite_set_origin(self->sprite, MakeVector(0.5f, 1.0f)); return self; } Prop* SpawnProp(Vector location, Sprite* sprite, Shape* shape) { Prop* self = MakeProp(sprite, shape); self->transform.position = rigidbody_get_transform(self->rigidbody)->position = location; game_world_add_entity(Prop_as_BehaviourEntity(self)); physics_world_add_entity(Prop_as_PhysicsEntity(self)); return self; } void DestroyProp(Prop* self) { sprite_destroy(self->sprite); rigidbody_destroy(self->rigidbody); shape_destroy(self->collisionShape); free(self); } void PropStart(Prop* self) {} void PropUpdate(Prop* self, float deltaTime) {} void PropDraw(Prop* self) { sprite_draw(self->sprite, self->transform); shape_draw(self->collisionShape, self->transform); } void PropOnCollision(Prop* self, Collision collision) {} void PropOnOverlap(Prop* self, PhysicsEntity other) {} Transform* PropGetTransform(Prop* self) { return &self->transform; } RigidBody* PropGetRigidBody(Prop* self) { return self->rigidbody; } Shape* PropGetCollisionShape(Prop* self) { return self->collisionShape; }