Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualParadigm Shifter

Posted 25 June 2013 - 06:14 AM

You don't need trig to do that. Alvaro already said what they need to do.

sf::Vector2f mousePos = your mouse position vector;
sf::Vector2f shipPos = you ship position vector;
sf::Vector2f bulletVelocity(mousePos.x - shipPos.x, mousePos.y - shipPos.y); // see comment in next post
sf::Vector2f bulletPosition = bullet position;

bulletVelocity.normalize();

bulletVelocity *= bulletSpeed;

bulletPosition.x += bulletVelocity.x;
bulletPosition.y += bulletVelocity.y;

#2Paradigm Shifter

Posted 25 June 2013 - 05:15 AM

You don't need trig to do that. Alvaro already said what they need to do.

sf::Vector2f mousePos = your mouse position vector;
sf::Vector2f shipPos = you ship position vector;
sf::Vector2f bulletVelocity(mousePos.y - shipPos.y, mousePos.x - shipPos.x);
sf::Vector2f bulletPosition = bullet position;

bulletVelocity.normalize();

bulletVelocity *= bulletSpeed;

bulletPosition.x += bulletVelocity.x;
bulletPosition.y += bulletVelocity.y;

#1Paradigm Shifter

Posted 25 June 2013 - 05:14 AM

You don't need trig to do that. Alvaro already said what they need to do.

sf::Vector2f mousePos = your mouse position vector;
sf::Vector2f shipPos = you ship position vector;
sf::Vector2f bulletVelocity(mousePos.y - shipPos.y, mousePos.x - shipPos.x);
sf::Vector2f bulletPosition = bullet position;

bulletVelocity.normalize();

bulletVeloctiy *= bulletSpeed;

bulletPosition.x += bulletVelocity.x;
bulletPosition.y += bulletVelocity.y;

PARTNERS