Multiple fixes
Obracające się meteoryty, koniec gry przy natrafieniu na meteoryt. Poprawione sprajty statku, meteorytu i pocisku
This commit is contained in:
@@ -5,11 +5,13 @@ Meteor::Meteor(float x, float y, sf::Texture &texture) {
|
||||
outOfBounds = false;
|
||||
meteorTexture = texture;
|
||||
meteorSprite.setTexture(texture);
|
||||
meteorSprite.setOrigin(meteorSprite.getLocalBounds().width / 2, meteorSprite.getLocalBounds().height / 2); // wycentrowanie sprite
|
||||
meteorSprite.setPosition(x, y);
|
||||
meteorSpeed = 5.0f;
|
||||
meteorSprite.scale(0.05f, 0.05f);
|
||||
meteorPosition.x = x;
|
||||
meteorPosition.y = y;
|
||||
meteorRotationSpeed = static_cast<float>(rand() % 2 + 1) * (rand() % 2 == 0 ? 1 : -1);
|
||||
}
|
||||
|
||||
sf::Sprite &Meteor::getSprite() {
|
||||
@@ -17,11 +19,14 @@ sf::Sprite &Meteor::getSprite() {
|
||||
}
|
||||
|
||||
void Meteor::update() {
|
||||
meteorSprite.move(0.0f, meteorSpeed);
|
||||
meteorPosition.y += int(meteorSpeed);
|
||||
if(meteorPosition.y > 800) {
|
||||
outOfBounds = true;
|
||||
meteorSprite.move(0.0f, meteorSpeed); // przesunięcie sprajta
|
||||
meteorPosition.y += int(meteorSpeed); // przesunięcie pozycji
|
||||
meteorSprite.rotate(meteorRotationSpeed); // obracanie tym meteorkiem pięknym
|
||||
if(meteorPosition.y > 900) {
|
||||
outOfBounds = true; // jeżeli wyszedł poza granice ekranu ustaw tą zmienną
|
||||
}
|
||||
// std::cout << "x: " << meteorSprite.getPosition().x << std::endl;
|
||||
// std::cout << "y: " << meteorSprite.getPosition().y << std::endl;
|
||||
}
|
||||
|
||||
bool Meteor::getStatus() {
|
||||
|
||||
Reference in New Issue
Block a user