I have another question. So I'm creating a projectile in the form of an orb. I currently am able to have it move to a certain point and despawn, but I am unable to get it to reset the orb's location so it can do it again.
//Code for Player Ability
if (orbMovement == true)
{
float move = velocity.x += 4;
pOrb.setPosition(pImage.getPosition().x + 40, pImage.getPosition().y + 20);
pOrb.move(move, 0);
window.draw(pOrb);
if (pOrb.getPosition().x >= pImage.getPosition().x + 300)
orbMovement = false;
}
if (orbMovement == false)
{
pOrb.setPosition(pImage.getPosition().x, pImage.getPosition().y);
}
and in the main function I'm using a switch statement that when 'F' is pressed it sets orbMovement to True as shown here,
if (evnt.key.code == sf::Keyboard::F)
{
CreateAbilitySound();
orbMovement = true;
}
I want it to once it moves to the maximum distance, the orb resets position and can do it again.