Added heart and spawn of them

This commit is contained in:
2024-12-05 14:52:00 +01:00
parent b6830c305b
commit 3b637508e1
5 changed files with 81 additions and 6 deletions

23
sources/Heart.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "../headers/Heart.hpp"
Heart::Heart(float x, float y, sf::Texture &texture) : ObjectItem(x,y,texture) {
outOfBounds = false;
texture = texture;
sprite.setTexture(texture);
sprite.setOrigin(sprite.getLocalBounds().width / 2, sprite.getLocalBounds().height / 2); // wycentrowanie sprite
sprite.setPosition(x, y);
movingSpeed = 3.0f;
// sprite.scale(0.05f, 0.05f);
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
// sprite.rotate(rotationSpeed); // obracanie tym meteorkiem pięknym
if(position.y > 900) {
outOfBounds = true; // jeżeli wyszedł poza granice ekranu ustaw tą zmienną
}
}