Meteory są w tym samym stanie co w poprzednim commit, tylko, że teraz są zdefiniowane w osobnej klasie "Plansza"

This commit is contained in:
2024-11-20 14:01:43 +01:00
parent cf10a042c0
commit 1cd9f9b950
8 changed files with 84 additions and 39 deletions

View File

@@ -1,15 +1,14 @@
#include <iostream>
#include "../headers/Meteor.h"
Meteor::Meteor(int x, int y, sf::Texture &texture) {
position.x = x;
position.y = y;
Meteor::Meteor(float x, float y, sf::Texture &texture) {
outOfBounds = false;
meteorTexture = texture;
meteorSprite.setTexture(texture);
meteorSpeed = 10.0f;
meteorSprite.setPosition(x, y);
meteorSpeed = 10.0f;
meteorSprite.scale(0.05f, 0.05f);
meteorPosition.x = x;
meteorPosition.y = y;
}
sf::Sprite &Meteor::getSprite() {
@@ -18,8 +17,8 @@ sf::Sprite &Meteor::getSprite() {
void Meteor::update() {
meteorSprite.move(0.0f, meteorSpeed);
position.y += int(meteorSpeed);
if(position.y > 900) {
meteorPosition.y += int(meteorSpeed);
if(meteorPosition.y > 900) {
outOfBounds = true;
}
}