Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Player::EnemyMoved(sf::RenderWindow &window){
- this->enemyPosition = enemyImage.getPosition();
- //this->mouse = window.mapPixelToCoords(sf::Mouse::getPosition(window));
- const float PI = 3.14159265;
- float d = enemyPosition.x - playerPosition.x + 50;
- float e = enemyPosition.y - playerPosition.y + 50;
- enemyAngle = (atan2(e, d)) * 180 / PI;
- enemyImage.setRotation(enemyAngle + 270);
- if (abs(sqrt(((playerPosition.x - enemyPosition.x + 200) * (playerPosition.x - enemyPosition.x + 200)) + ((playerPosition.y - enemyPosition.y + 200) * (playerPosition.y - enemyPosition.y + 200))))){
- enemyImage.move(std::cos(3.14159265 * enemyAngle / 180.f) * 1.0f *-1, std::sin(3.14159265 * enemyAngle / 180.f) * 1.0f *-1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement