20 lines
674 B
C++
20 lines
674 B
C++
#include "../headers/Heart.hpp"
|
|
|
|
Heart::Heart(float x, float y, sf::Texture &texture) : ObjectItem(x,y,texture) {
|
|
texture_ = texture;
|
|
sprite.setTexture(texture_);
|
|
sprite.setOrigin(sprite.getLocalBounds().width / 2, sprite.getLocalBounds().height / 2); // wycentrowanie sprite
|
|
sprite.setPosition(x, y);
|
|
movingSpeed = 3.0f;
|
|
position.x = x;
|
|
position.y = y;
|
|
rotationSpeed = 0;
|
|
}
|
|
|
|
void Heart::update() {
|
|
sprite.move(0.0f, movingSpeed); // przesunięcie sprajta
|
|
position.y += int(movingSpeed); // przesunięcie pozycji
|
|
if(position.y > 900) {
|
|
outOfBounds = true; // jeżeli wyszedł poza granice ekranu ustaw tą zmienną
|
|
}
|
|
} |