Hey SFML coders !
How do i get a sprite to be fired as projectile and move straight ahead .
Please explain Precise and simple ... your knowledge will be appreciated
Here is the code i have.
/////////////////////////////
///Create the bullet
////////////////////////////
void Bullet::createBullet(sf::Texture &bulletTexture, sf::Sprite &bulletImage, sf::Sprite &shipImage)
{
if(!bulletTexture.loadFromFile("Images/missile.png"))///creates the bullet
cout << "ERROR:bullet could not load" << endl;
bulletImage.setTexture(bulletTexture);///
sf::Vector2f shipLocation = shipImage.getPosition(); ///Gets the location of the ship
float locationX = shipLocation.x - 83;///sets the X location of the ship places the bullet of it
float locationY= shipLocation.y +4 ;///sets the Y loction of the ship
bulletImage.setPosition(locationX, locationY);
}
////////////////////////
///Move the bullet
////////////////////////
void Bullet::moveBullet(sf::Sprite &bulletImage, sf::Sprite &shipImage)
{
float moveX = shipImage.getPosition().x;
bulletImage.move(-3,0);
}