Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. if(!alive){
  2. return;
  3. }
  4. xPos += t * velocity/10000 * cos(direction / 180 * 3.14);
  5. yPos += t * velocity/10000 * sin(direction / 180 * 3.14);
  6.  
  7. double gravity = 1000;
  8. double starX = 1920/2;
  9. double starY = 1080/2;
  10.  
  11. double deltaX = xPos - starX;
  12. double deltaY = yPos - starY;
  13. double distance = sqrt(pow(deltaX, 2) + pow(deltaY, 2));
  14. int modifier = 1;
  15. if (xPos > starX){
  16. modifier = -1;
  17. }
  18. double angle = atan(deltaY / deltaX) * 180 / 3.14;
  19. std::cout << angle << std::endl;
  20.  
  21. xPos += t * gravity / pow(distance,2) * modifier * cos(angle / 180 * 3.14);
  22. yPos += t * gravity / pow(distance,2) * modifier * sin(angle / 180 * 3.14);
  23.  
  24. if (xPos > starX - 100 && xPos < starX + 100 && yPos > starY - 100 && yPos < starY + 100){
  25. alive = false;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement