#include <iostream>
#include "../headers/Bullet.h"

Bullet::Bullet(float x, float y, sf::Texture &texture) {
    bulletPosition.x = x;
    bulletPosition.y = y;
    outOfBounds = false;
    bulletTexture = texture;
    bulletSprite.setTexture(texture);
    bulletSprite.setOrigin(bulletSprite.getLocalBounds().width/2, bulletSprite.getLocalBounds().height/2);
    bulletSprite.setPosition(x, y);
    bulletSpeed = -10.0f;
}

void Bullet::setSpeed(float speed) {
    bulletSpeed = speed;
}

sf::Sprite &Bullet::getSprite() {
    return bulletSprite;
}

void Bullet::update() {
    bulletSprite.move(0.0f, bulletSpeed);
    bulletPosition.y += int(bulletSpeed);
    if(bulletPosition.y < -100) {
        outOfBounds = true;
    }
}

bool Bullet::getStatus() const {
    return outOfBounds;
}
