Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rya729

Member Since 06 Oct 2011
Offline Last Active Mar 30 2012 11:00 AM

Posts I've Made

In Topic: Basic game phyics problem

28 March 2012 - 11:40 AM

Thanks for the input guys. However i have wrote this and i have a problem, so any help would be great.
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>

int main()
{
    int x = 0;
    int y = 380;
    int clickX = 40;
    int clickY = 360;
    float angleRadians,angleDregees,maxVelocity;
    float xVel,yVel;
    int b;
   
    maxVelocity = 100;   
   
    //The angle in radians
    angleRadians = atan((y-clickY)/(clickX-x));
    //The angle in degrees
    angleDregees = (angleRadians * 180 / M_PI);
    //velocitys
    xVel = ceil(((90-angleDregees)/90)*maxVelocity);
    yVel = ceil((angleDregees/90)*maxVelocity);
    
    std::cout << "angle in radians :" << angleRadians << std::endl;
    std::cout << "angle in degees :" << angleDregees << std::endl;
    std::cout << "xVelocity :" << xVel << std::endl;
    std::cout << "yVelocity :" << yVel << std::endl;  
    std::cin >> b;
}
 

It ethier gives me 100 xVel or 100 yVel or 50/50. When i change the values, thanks for any help :)

PARTNERS