diff --git a/assets/img/Rocket_111.png b/assets/img/Rocket_111.png new file mode 100644 index 0000000..fa76649 Binary files /dev/null and b/assets/img/Rocket_111.png differ diff --git a/assets/img/Rocket_115.png b/assets/img/Rocket_115.png new file mode 100644 index 0000000..bf18330 Binary files /dev/null and b/assets/img/Rocket_115.png differ diff --git a/assets/img/meteor-1.png b/assets/img/meteor-1.png new file mode 100644 index 0000000..74254b6 Binary files /dev/null and b/assets/img/meteor-1.png differ diff --git a/assets/img/meteor.png b/assets/img/meteor.png deleted file mode 100644 index 512c494..0000000 Binary files a/assets/img/meteor.png and /dev/null differ diff --git a/assets/ship/Dreadnought-Base.png b/assets/ship/Dreadnought-Base.png index 70cbf76..3944b15 100644 Binary files a/assets/ship/Dreadnought-Base.png and b/assets/ship/Dreadnought-Base.png differ diff --git a/main.cpp b/main.cpp index 68e3b29..d4435b2 100644 --- a/main.cpp +++ b/main.cpp @@ -88,8 +88,8 @@ int main() for (auto& meteor : plansza.getMeteors()) { if(ship.getSprite().getGlobalBounds().intersects(meteor.getSprite().getGlobalBounds())) { std::cout << "You lost the game!\n"; - window.close(); - exit(-2); // Kod -2 oznacza uderzenie się w meteoryt + // window.close(); + // exit(-2); // Kod -2 oznacza uderzenie się w meteoryt } } diff --git a/sources/Actor.cpp b/sources/Actor.cpp index 91edb2f..ae74aff 100644 --- a/sources/Actor.cpp +++ b/sources/Actor.cpp @@ -5,7 +5,7 @@ Actor::Actor(int x, int y, std::string path) { position.x = x; position.y = y; actorSprite.setOrigin(actorSprite.getLocalBounds().width / 2, actorSprite.getLocalBounds().height / 2); // wycentrowanie sprite - actorSprite.setPosition(x, y); + actorSprite.setPosition(float(x), float(y)); } void Actor::loadTexture(std::string path) { @@ -13,7 +13,7 @@ void Actor::loadTexture(std::string path) { actorSprite.setTexture(actorTexture); bulletTextureLeft.loadFromFile("../assets/img/bullet_left.png"); - bulletTextureRight.loadFromFile("../assets/img/bullet_right.png"); + bulletTextureRight.loadFromFile("../assets/img/Rocket_111.png"); } sf::Sprite &Actor::getSprite() { @@ -25,7 +25,7 @@ Position Actor::getPosition() { } void Actor::shoot() { - bullets.emplace_back(float(position.x) + actorSprite.getGlobalBounds().width / 2-62, position.y, bulletTextureLeft); + bullets.emplace_back(float(position.x) + actorSprite.getGlobalBounds().width / 2, position.y, bulletTextureLeft); } std::vector &Actor::getBullets() { diff --git a/sources/Bullet.cpp b/sources/Bullet.cpp index d17a356..dc9f8a6 100644 --- a/sources/Bullet.cpp +++ b/sources/Bullet.cpp @@ -2,14 +2,14 @@ #include "../headers/Bullet.h" Bullet::Bullet(float x, float y, sf::Texture &texture) { + bulletPosition.x = x; + bulletPosition.y = y; outOfBounds = false; bulletTexture = texture; bulletSprite.setTexture(texture); bulletSprite.setOrigin(bulletSprite.getLocalBounds().width/2, bulletSprite.getLocalBounds().height/2); bulletSprite.setPosition(x, y); bulletSpeed = -10.0f; - bulletPosition.x = x; - bulletPosition.y = y; } void Bullet::setSpeed(float speed) { diff --git a/sources/Plansza.cpp b/sources/Plansza.cpp index 305cead..3024c89 100644 --- a/sources/Plansza.cpp +++ b/sources/Plansza.cpp @@ -5,7 +5,7 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth) { size.height = windowHeight; size.width = windowWidth; - meteorTexture.loadFromFile("../assets/img/meteor.png"); + meteorTexture.loadFromFile("../assets/img/meteor-1.png"); spawnClock.restart(); } diff --git a/sources/Player.cpp b/sources/Player.cpp index 78257e5..08233c1 100644 --- a/sources/Player.cpp +++ b/sources/Player.cpp @@ -5,7 +5,7 @@ Player::Player(int x, int y, std::string path) : Actor(x, y, path) {}; void Player::shoot() { auto now = std::chrono::steady_clock::now(); if (std::chrono::duration_cast(now - lastShotTime).count() >= firerate) { - bullets.emplace_back(float(position.x) + actorSprite.getGlobalBounds().width / 2, position.y, bulletTextureLeft); + bullets.emplace_back(position.x, position.y, bulletTextureLeft); lastShotTime = now; } } @@ -13,7 +13,7 @@ void Player::shoot() { void Player::alternate_shoot() { auto now = std::chrono::steady_clock::now(); if (std::chrono::duration_cast(now - lastShotTime).count() >= firerate) { - bullets.emplace_back(float(position.x) + actorSprite.getGlobalBounds().width / 2, position.y, bulletTextureRight); + bullets.emplace_back(position.x, position.y, bulletTextureRight).getSprite().scale(1.5f, 1.5f); lastShotTime = now; } } @@ -28,20 +28,20 @@ void Player::move(float deltaX, float deltaY) { void Player::moveLeft() { move(-moving_speed, 0.0f); - position.x -= moving_speed; + position.x -= static_cast(moving_speed); } void Player::moveRight() { move(moving_speed, 0.0f); - position.x += moving_speed; + position.x += static_cast(moving_speed); } void Player::moveUp() { move(0.0f, -moving_speed); - position.y -= moving_speed; + position.y -= static_cast(moving_speed); } void Player::moveDown() { move(0.0f, moving_speed); - position.y += moving_speed; + position.y += static_cast(moving_speed); } \ No newline at end of file