class Shoot{
public:
Shoot(sf::Vector2f size) {
shoot.setSize(size);
shoot.setFillColor(sf::Color::Red);
}
void fire(float speed) {
shoot.move(speed , 0);
}
int getRight() {
return shoot.getPosition().x + shoot.getSize().x;
}
int getLeft() {
return shoot.getPosition().x ;
}
int getTop() {
return shoot.getPosition().y;
}
int getBottom() {
return shoot.getPosition().y + shoot.getSize().y;
}
void draw(sf::RenderWindow &window) {
window.draw(shoot);
}
void setPos(sf::Vector2f newPos) {
shoot.setPosition(newPos);
}
void rotate(float angle)
{
shoot.setRotation(angle);
}
private:
sf::RectangleShape shoot;
};
//shooting
if (isFiring == true) {
Shoot newShoot(sf::Vector2f(20, 5));
newShoot.setPos(sf::Vector2f(circle.getPosition().x, circle.getPosition().y));
newShoot.rotate(90 + atan2f((mousePosition.y - circle.getPosition().y ), (mousePosition.x - circle.getPosition().x )) * 180 / Pi);
shootVect.push_back(newShoot);
isFiring = false;
}
for (int i = 0; i < shootVect.size(); i++) {
shootVect[i].draw(window);
shootVect[i].fire(speed);
}