Zmiana sposobu tworzenia gracza.

Użyto singleton pattern.
Zmieniono konstruktor klasy Plansza
This commit is contained in:
2024-12-13 13:36:41 +01:00
parent 3f4a937257
commit 8b4b25747e
7 changed files with 139 additions and 142 deletions

View File

@@ -5,16 +5,20 @@
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>
#include "../headers/Bullet.h"
Player::Player(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
Player::Player(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture, const sf::Texture& rocketTexture) : Actor(x, y, texture), bulletTexture(bulletTexture), rocketTexture(rocketTexture) {
}
};
Player* Player::getInstance(int x, int y, const sf::Texture& texture) {
if (player_ == nullptr) {
player_ = new Player(x, y, texture);
}
return player_;
}
void Player::setTextures(const sf::Texture& shipTexture, const sf::Texture& bulletTexture, const sf::Texture& rocketTexture) {
this->actorSprite.setTexture(shipTexture); // Poprawiona nazwa - actorSprite zamiast shipSprite
this->bulletTexture = bulletTexture;
this->rocketTexture = rocketTexture;
void Player::loadTexture() {
bulletTexture.loadFromFile("../assets/img/bullets/bullet_pink.png");
rocketTexture.loadFromFile("../assets/img/rockets/Rocket_111.png");
}
void Player::shoot() {
@@ -106,3 +110,5 @@ void Player::moveDown() {
std::vector<Rocket> &Player::getRockets() {
return rockets;
}
Player* Player::player_ = nullptr;