• Create Account

### #ActualBeerNutts

Posted 13 March 2013 - 02:58 PM

Thanks but I have no idea how to read c++ so I have no idea what's going on lol

It should be obvious what it is doing by looking at the lines:

The 1st 2 lines are getting the X and Y coordinates of the mouse on the screen, storing them in variables MouseX and MouseY

The next line performs the atan2 function using the difference of the location of the mouse and the player on the screen (the player is ALWAYS at the center of the screen, that's why it uses mpApp->GetHeight()/2 and mpApp->GetWidth()/2

Think of it like this

// PlayerX and PlayerY are the x and y coordinates of the player on the screen
Angle = atan2(MouseY - PlayerY, MouseX - PlayerY);

// Take the Angle and apply it to your player's sprite or physical body
PlayerSprite->Rotate(Angle)


### #1BeerNutts

Posted 13 March 2013 - 02:57 PM

Thanks but I have no idea how to read c++ so I have no idea what's going on lol

It should be obvious what it is doing by looking at the lines:

The 1st 2 lines are getting the X and Y coordinates of the mouse on the screen, storing them in variables MouseX and MouseY

The next line performs the atan2 function using the difference of the location of the mouse and the player on the screen (the player is ALWAYS at the center of the screen, that's why it uses mpApp->GetHeight()/2 and mpApp->GetWidth()/2

Think of it like this

// PlayerX and PlayerY are the x and y coordinates of the player
Angle = atan2(MouseY - PlayerY, MouseX - PlayerY);

// Take the Angle and apply it to your player's sprite or physical body
PlayerSprite->Rotate(Angle)


PARTNERS