Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!alive){
- return;
- }
- xPos += t * velocity/10000 * cos(direction / 180 * 3.14);
- yPos += t * velocity/10000 * sin(direction / 180 * 3.14);
- double gravity = 1000;
- double starX = 1920/2;
- double starY = 1080/2;
- double deltaX = xPos - starX;
- double deltaY = yPos - starY;
- double distance = sqrt(pow(deltaX, 2) + pow(deltaY, 2));
- int modifier = 1;
- if (xPos > starX){
- modifier = -1;
- }
- double angle = atan(deltaY / deltaX) * 180 / 3.14;
- std::cout << angle << std::endl;
- xPos += t * gravity / pow(distance,2) * modifier * cos(angle / 180 * 3.14);
- yPos += t * gravity / pow(distance,2) * modifier * sin(angle / 180 * 3.14);
- if (xPos > starX - 100 && xPos < starX + 100 && yPos > starY - 100 && yPos < starY + 100){
- alive = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement