I had written fireball shoots and it's work's fine but it's designed only for one fireball at the moment so if i want to shoot 2 or more i must wait until my last die..English is not my strong suit...
How can i fix it ?
Fireball code :
if(sf::Keyboard::isKeyPressed(sf::Keyboard::G))
{
FireballState = true; // Exist or not
}
if(FireballState)
{
if(FireballSpeed.getElapsedTime().asMilliseconds() > 2 ) // Speed of change fireball frames
{
FireballSpeed.restart();
vfireball.x = 7;
vfireball.y = 1;
fireballmove = 1; /
Fireball.setTextureRect(sf::IntRect(vfireball.x * 26, vfireball.y * 27, 27, 27));
if(source.y == Down && i == 0) // source.y is my charecter direction
{
FireballDown = true;
Fireball.setPosition(sprite.getPosition().x, sprite.getPosition().y + 20);
}
else if(source.y == Left && i == 0)
{
FireballLeft = true;
Fireball.setPosition(sprite.getPosition().x - 20, sprite.getPosition().y );
}
else if(source.y == Right && i == 0)
{
FireballRight = true;
Fireball.setPosition(sprite.getPosition().x + 20, sprite.getPosition().y );
}
else if(source.y == Up && i == 0)
{
FireballUp = true;
Fireball.setPosition(sprite.getPosition().x, sprite.getPosition().y - 20 );
}
if (FireballDown)
{
Fireball.move( 0, fireballmove);
}
else if(FireballRight)
{
Fireball.move( fireballmove,0);
}
else if (FireballLeft)
{
Fireball.move( -fireballmove , 0);
}
else if (FireballUp)
{
Fireball.move( 0 , -fireballmove );
}
i++;
Window.clear();
Window.draw(Fireball);
}
if(i == 500) // There will be some smarter condition of fireball death when i'll have something except emptiness and character
{
=
FireballState = false;
i = 0;
FireballUp = false;
FireballRight = false;
FireballLeft = false;
FireballDown = false;
}
}