This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // See RotateToMouse.cpp for definition of delta | |
| sf::Vector2f normalizedDelta(delta / hypot(delta.x, delta.y)); | |
| if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) | |
| background.move(sf::Vector2f(-normalizedDelta.x, -normalizedDelta.y)); | |
| if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) | |
| background.move(sf::Vector2f(normalizedDelta.x, normalizedDelta.y)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sf::Vector2f delta(sf::Vector2f(sf::Mouse::getPosition(window)) - player.getPosition()); | |
| player.setRotation(atan(delta.y / delta.x) * 180 / PI); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| auto box_position{sf::Mouse::getPosition(window)}; | |
| for (auto& component : {box_position.x, box_position.y}) | |
| { | |
| while (component % tileSize) | |
| --component; | |
| } | |
| box.setPosition(box_position); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For x | |
| // For y | |
| currentTile.setPosition((tileSize + border) * y, (tileSize + border) * x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| windowSize = boardSize * (tileSize + border) - border; |
NewerOlder