mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 12:33:43 +00:00
28 lines
623 B
C++
28 lines
623 B
C++
#include "ColliderComponent.h"
|
|
#include "TransformComponent.h"
|
|
#include "Entity.h"
|
|
#include "Game.h"
|
|
|
|
ColliderComponent::ColliderComponent(const char* tag)
|
|
{
|
|
this->tag = tag;
|
|
}
|
|
|
|
void ColliderComponent::init()
|
|
{
|
|
if (!entity->hasComponent<TransformComponent>())
|
|
{
|
|
entity->addComponent<TransformComponent>();
|
|
}
|
|
transform = &entity->getComponent<TransformComponent>();
|
|
Game::colliders.push_back(this);
|
|
}
|
|
|
|
void ColliderComponent::update()
|
|
{
|
|
collider.x = transform->position.x;
|
|
collider.y = transform->position.y;
|
|
|
|
collider.w = transform->width * transform->scale;
|
|
collider.h = transform->height * transform->scale;
|
|
} |