#include "bullet.hpp"
#include "../world.hpp"

#include <cstdio>

namespace game::entity {

Bullet::Bullet(World *world, const vec2f &position, float speed, float angle, float damage):
    BasicBullet(world, position, speed, angle) {
    this->damage = damage;
    this->Setup();
}

void Bullet::Setup()
{
    b2CircleShape shape;
    shape.m_radius = 0.2;

    b2FixtureDef fixDef;
    fixDef.filter.categoryBits = TYPE_BULLET;
    fixDef.filter.maskBits = TYPE_ENEMY | TYPE_WALL;
    fixDef.shape = &shape;
    fixDef.density = 1.0f;
    fixDef.userData = this;

    this->body->CreateFixture(&fixDef);
}

void Bullet::Render() noexcept
{
    render::primitives2d::circle(this->position, vec2f{0.25, 0.1}, color::yellow, this->angle, 8);
}

}
