Utilisation de la construction make_shared/make_unique
This commit is contained in:
parent
6808bfe5b7
commit
de3d4f6311
|
@ -13,7 +13,7 @@ protected:
|
|||
/**
|
||||
* Calcule les forces appliquées à l'objet
|
||||
*/
|
||||
virtual sf::Vector2f getForces(const Manager& manager, const std::vector<Object*>& objects) const;
|
||||
virtual sf::Vector2f getForces(const Manager& manager, const std::vector<ObjectPtr>& objects) const;
|
||||
|
||||
public:
|
||||
Player(float x, float y);
|
||||
|
|
|
@ -36,11 +36,11 @@ void Block::draw(Manager& manager) {
|
|||
}
|
||||
|
||||
std::unique_ptr<sf::FloatRect> Block::getAABB() const {
|
||||
return std::unique_ptr<sf::FloatRect>(new sf::FloatRect(
|
||||
return std::make_unique<sf::FloatRect>(
|
||||
getPosition().x - Constants::GRID / 2,
|
||||
getPosition().y - Constants::GRID / 2,
|
||||
Constants::GRID, Constants::GRID
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
unsigned int Block::getTypeId() const {
|
||||
|
|
|
@ -11,7 +11,7 @@ Player::Player(float x, float y) : Object(x, y) {
|
|||
|
||||
Player::~Player() {}
|
||||
|
||||
sf::Vector2f Player::getForces(const Manager& manager, const std::vector<Object*>& objects) const {
|
||||
sf::Vector2f Player::getForces(const Manager& manager, const std::vector<ObjectPtr>& objects) const {
|
||||
sf::Vector2f forces = Object::getForces(manager, objects);
|
||||
|
||||
// déplacement de la balle après appui sur les touches de direction
|
||||
|
@ -53,11 +53,11 @@ void Player::draw(Manager& manager) {
|
|||
}
|
||||
|
||||
std::unique_ptr<sf::FloatRect> Player::getAABB() const {
|
||||
return std::unique_ptr<sf::FloatRect>(new sf::FloatRect(
|
||||
return std::make_unique<sf::FloatRect>(
|
||||
getPosition().x - getRadius(),
|
||||
getPosition().y - getRadius(),
|
||||
2 * getRadius(), 2 * getRadius()
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
unsigned int Player::getTypeId() const {
|
||||
|
|
Loading…
Reference in New Issue