Zmiana sposobu tworzenia gracza.
Użyto singleton pattern. Zmieniono konstruktor klasy Plansza
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user