summary refs log tree commit diff stats
path: root/src/components.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/components.cpp')
-rw-r--r--src/components.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/components.cpp b/src/components.cpp index 5f67934..26aa5d2 100644 --- a/src/components.cpp +++ b/src/components.cpp
@@ -585,3 +585,30 @@ bool MapCollisionComponent::processCollision(Game& game, Entity& collider, Colli
585 585
586 return false; 586 return false;
587} 587}
588
589// Static image
590
591StaticImageComponent::StaticImageComponent(const char* filename) : sprite(Texture(filename))
592{
593
594}
595
596void StaticImageComponent::render(Game&, Entity& entity, Texture& buffer)
597{
598 buffer.blit(sprite, sprite.entirety(), {(int) entity.position.first, (int) entity.position.second, entity.size.first, entity.size.second});
599}
600
601// Simple collision
602
603SimpleColliderComponent::SimpleColliderComponent(std::function<void (Entity& collider)> callback) : callback(callback)
604{
605
606}
607
608void SimpleColliderComponent::receive(Game&, Entity&, const Message& msg)
609{
610 if (msg.type == Message::Type::collision)
611 {
612 callback(*(msg.collisionEntity));
613 }
614}