Compare commits
7 Commits
0834460e82
...
ultimateIm
| Author | SHA1 | Date | |
|---|---|---|---|
| bad49c78a5 | |||
| f5d9bae6e9 | |||
| 696714cf9a | |||
| 3c0cd4b950 | |||
| bafab8d75a | |||
| 92d5f66a91 | |||
| 622e814d1c |
BIN
assets/img/ultimate/ultimate_0.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/img/ultimate/ultimate_10.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/img/ultimate/ultimate_100.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/img/ultimate/ultimate_20.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/img/ultimate/ultimate_30.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/img/ultimate/ultimate_40.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/img/ultimate/ultimate_50.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/img/ultimate/ultimate_60.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
assets/img/ultimate/ultimate_70.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
assets/img/ultimate/ultimate_80.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
assets/img/ultimate/ultimate_90.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
assets/sounds/destroyed.ogg
Normal file
@@ -50,6 +50,8 @@ public:
|
|||||||
void check_Meteor_collisions();
|
void check_Meteor_collisions();
|
||||||
void check_Debuff_collisions();
|
void check_Debuff_collisions();
|
||||||
|
|
||||||
|
void handleUltimate();
|
||||||
|
|
||||||
void spawn_player();
|
void spawn_player();
|
||||||
void spawn_enemy();
|
void spawn_enemy();
|
||||||
void spawn_advanced_enemy();
|
void spawn_advanced_enemy();
|
||||||
@@ -64,7 +66,9 @@ public:
|
|||||||
|
|
||||||
static ships selectedShip;
|
static ships selectedShip;
|
||||||
static unsigned int score;
|
static unsigned int score;
|
||||||
|
static unsigned int ultimateCounter;
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Background background;
|
Background background;
|
||||||
AudioManager audioManager;
|
AudioManager audioManager;
|
||||||
@@ -84,7 +88,7 @@ private:
|
|||||||
sf::Clock heartSpawnClock;
|
sf::Clock heartSpawnClock;
|
||||||
sf::Clock powerUpSpawnClock;
|
sf::Clock powerUpSpawnClock;
|
||||||
sf::Clock debuffSpawnClock;
|
sf::Clock debuffSpawnClock;
|
||||||
// sf::Clock spawnClock;
|
sf::Clock ultimateClock;
|
||||||
sf::Clock scoreClock;
|
sf::Clock scoreClock;
|
||||||
sf::Clock shooterSpawnClock;
|
sf::Clock shooterSpawnClock;
|
||||||
sf::Clock enemySpawnClock;
|
sf::Clock enemySpawnClock;
|
||||||
@@ -116,6 +120,7 @@ private:
|
|||||||
sf::Texture movingSpeedDebuffTexture;
|
sf::Texture movingSpeedDebuffTexture;
|
||||||
sf::Texture firerateDebuffTexture;
|
sf::Texture firerateDebuffTexture;
|
||||||
sf::Texture bulletSpeedDebuffTexture;
|
sf::Texture bulletSpeedDebuffTexture;
|
||||||
|
sf::Texture ultimateIndicatorTextures[11];
|
||||||
|
|
||||||
// Tablice
|
// Tablice
|
||||||
std::vector<Enemy> enemies;
|
std::vector<Enemy> enemies;
|
||||||
@@ -128,11 +133,14 @@ private:
|
|||||||
std::vector<sf::Sprite> heartStats;
|
std::vector<sf::Sprite> heartStats;
|
||||||
std::vector<PowerUp> powerUps;
|
std::vector<PowerUp> powerUps;
|
||||||
std::vector<Debuff> debuffs;
|
std::vector<Debuff> debuffs;
|
||||||
|
std::vector<sf::Sprite> ultimateIndicators;
|
||||||
|
|
||||||
|
void loadUltimateIndicators();
|
||||||
|
|
||||||
// Zmienne prymitywne
|
// Zmienne prymitywne
|
||||||
Boss* boss = nullptr; // Wskaźnik na bossa
|
Boss* boss = nullptr; // Wskaźnik na bossa
|
||||||
sf::Clock bossSpawnClock; // Zegar do spawnowania bossa
|
sf::Clock bossSpawnClock; // Zegar do spawnowania bossa
|
||||||
unsigned int nextBossScoreThreshold = 1; // Próg punktowy dla spawnu bossa
|
unsigned int nextBossScoreThreshold = 1000; // Próg punktowy dla spawnu bossa
|
||||||
bool bossSpawned = false; // Flaga informująca, czy boss został już zespawnowany
|
bool bossSpawned = false; // Flaga informująca, czy boss został już zespawnowany
|
||||||
bool gameOver = false;
|
bool gameOver = false;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public:
|
|||||||
|
|
||||||
void shoot() override;
|
void shoot() override;
|
||||||
void alternate_shoot();
|
void alternate_shoot();
|
||||||
|
void ultimate_shoot();
|
||||||
void setFirerate(unsigned int firerate);
|
void setFirerate(unsigned int firerate);
|
||||||
void move(float deltaX, float deltaY) override;
|
void move(float deltaX, float deltaY) override;
|
||||||
void moveLeft() override;
|
void moveLeft() override;
|
||||||
@@ -30,13 +31,17 @@ public:
|
|||||||
void moveDown() override;
|
void moveDown() override;
|
||||||
void takeDamage();
|
void takeDamage();
|
||||||
void setTripleShot(bool toogle);
|
void setTripleShot(bool toogle);
|
||||||
void setBulletSpeed(float speed);
|
|
||||||
|
|
||||||
|
void setBulletSpeed(float speed);
|
||||||
|
bool getUltimateStatus();
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
std::vector<Rocket>& getRockets();
|
std::vector<Rocket>& getRockets();
|
||||||
|
|
||||||
void loadTexture();
|
void loadTexture();
|
||||||
|
|
||||||
|
void setUltimateStatus(bool status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
|
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
|
||||||
std::vector<Rocket> rockets;
|
std::vector<Rocket> rockets;
|
||||||
@@ -48,6 +53,7 @@ private:
|
|||||||
float bulletSpeed = 10.0f; // prędkość pocisku
|
float bulletSpeed = 10.0f; // prędkość pocisku
|
||||||
bool isImmortal = false; // flaga na immortal
|
bool isImmortal = false; // flaga na immortal
|
||||||
bool tripleShot = false; // flaga na potrójny strzał
|
bool tripleShot = false; // flaga na potrójny strzał
|
||||||
|
bool ultimateShootActive = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ AdvancedEnemy::AdvancedEnemy(int x, int y, const sf::Texture& texture, const sf:
|
|||||||
enemyBulletTexture = bulletTexture;
|
enemyBulletTexture = bulletTexture;
|
||||||
hp = 2; // 2 punkty życia
|
hp = 2; // 2 punkty życia
|
||||||
firerate = 2000; // Strzela co 2
|
firerate = 2000; // Strzela co 2
|
||||||
moving_speed = 2.0f; // Prędkość
|
moving_speed = 4.0f; // Prędkość
|
||||||
enemyBulletTexture.loadFromFile("../assets/img/bullets/enemy_bullet.png");
|
enemyBulletTexture.loadFromFile("../assets/img/bullets/enemy_bullet.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,5 +86,6 @@ void AdvancedEnemy::takeDamage() {
|
|||||||
if (--hp <= 0) {
|
if (--hp <= 0) {
|
||||||
alive = false;
|
alive = false;
|
||||||
Plansza::score += 10;
|
Plansza::score += 10;
|
||||||
|
Plansza::ultimateCounter += 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
Bomber::Bomber(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture) : Actor(x, y, texture) {
|
Bomber::Bomber(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture) : Actor(x, y, texture) {
|
||||||
BombaTexture = bulletTexture;
|
BombaTexture = bulletTexture;
|
||||||
hp = 2; // 2 punkty życia
|
hp = 2; // 2 punkty życia
|
||||||
firerate = 10000; // Strzela co 10
|
firerate = 6000; // Strzela co 6
|
||||||
moving_speed = 10.0f; // Prędkość
|
moving_speed = 8.0f; // Prędkość
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bomber::setPlanszaHeight(float height, float width) {
|
void Bomber::setPlanszaHeight(float height, float width) {
|
||||||
@@ -122,5 +122,6 @@ void Bomber::takeDamage() {
|
|||||||
if (--hp <= 0) {
|
if (--hp <= 0) {
|
||||||
alive = false;
|
alive = false;
|
||||||
Plansza::score += 15;
|
Plansza::score += 15;
|
||||||
|
Plansza::ultimateCounter += 15;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ Boss::Boss(int x, int y, const sf::Texture& bossTexture, const sf::Texture& bull
|
|||||||
}
|
}
|
||||||
hp = 100;
|
hp = 100;
|
||||||
firerate = 2000;
|
firerate = 2000;
|
||||||
movementSpeed = 2.0f;
|
movementSpeed = 3.0f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
Enemy::Enemy(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
|
Enemy::Enemy(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
|
||||||
hp = 1; // Przeciwnik ma 1 punkt życia
|
hp = 1; // Przeciwnik ma 1 punkt życia
|
||||||
firerate = 2000; // Strzela co 2
|
firerate = 2000; // Strzela co 2
|
||||||
moving_speed = 2.0f; // Prędkość
|
moving_speed = 2.5f; // Prędkość
|
||||||
enemyBulletTexture.loadFromFile("../assets/img/bullets/enemy_bullet.png");
|
enemyBulletTexture.loadFromFile("../assets/img/bullets/enemy_bullet.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,5 +76,6 @@ void Enemy::takeDamage() {
|
|||||||
if (--hp <= 0) {
|
if (--hp <= 0) {
|
||||||
alive = false;
|
alive = false;
|
||||||
Plansza::score += 5;
|
Plansza::score += 5;
|
||||||
|
Plansza::ultimateCounter += 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
Kamikadze::Kamikadze(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
|
Kamikadze::Kamikadze(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
|
||||||
hp = 3; // 3 punkty życia
|
hp = 3; // 3 punkty życia
|
||||||
moving_speed = 2.0f; // Prędkość
|
moving_speed = 5.0f; // Prędkość
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kamikadze::shoot(){}
|
void Kamikadze::shoot(){}
|
||||||
@@ -131,5 +131,6 @@ void Kamikadze::takeDamage() {
|
|||||||
if (--hp <= 0) {
|
if (--hp <= 0) {
|
||||||
alive = false;
|
alive = false;
|
||||||
Plansza::score += 20;
|
Plansza::score += 20;
|
||||||
|
Plansza::ultimateCounter += 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../headers/Plansza.h"
|
#include "../headers/Plansza.h"
|
||||||
#include "../headers/RandomNumberGenerator.h"
|
#include "../headers/RandomNumberGenerator.h"
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::RenderWindow *mainWindow, ships selectedShip)
|
Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::RenderWindow *mainWindow, ships selectedShip)
|
||||||
: background("../assets/img/background/background.png", 2.0f) {
|
: background("../assets/img/background/background.png", 2.0f) {
|
||||||
@@ -46,6 +47,8 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::Render
|
|||||||
exit(-500);
|
exit(-500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadUltimateIndicators();
|
||||||
|
|
||||||
score = 0;
|
score = 0;
|
||||||
|
|
||||||
// Wczytywanie czcionki dla licznika punktów
|
// Wczytywanie czcionki dla licznika punktów
|
||||||
@@ -60,6 +63,7 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::Render
|
|||||||
audioManager.loadSoundEffect("shoot", "../assets/sounds/shoot.ogg");
|
audioManager.loadSoundEffect("shoot", "../assets/sounds/shoot.ogg");
|
||||||
audioManager.loadSoundEffect("shoot_alt", "../assets/sounds/shoot_alt.ogg");
|
audioManager.loadSoundEffect("shoot_alt", "../assets/sounds/shoot_alt.ogg");
|
||||||
audioManager.loadSoundEffect("fail", "../assets/sounds/fail.mp3");
|
audioManager.loadSoundEffect("fail", "../assets/sounds/fail.mp3");
|
||||||
|
audioManager.loadSoundEffect("destroyed", "../assets/sounds/destroyed.ogg");
|
||||||
|
|
||||||
heartStats.emplace_back(heartTexture);
|
heartStats.emplace_back(heartTexture);
|
||||||
heartStats.emplace_back(heartTexture);
|
heartStats.emplace_back(heartTexture);
|
||||||
@@ -76,6 +80,35 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::Render
|
|||||||
// spawnClock.restart();
|
// spawnClock.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plansza::loadUltimateIndicators() {
|
||||||
|
const std::string texturePaths[11] = {
|
||||||
|
"../assets/img/ultimate/ultimate_0.png",
|
||||||
|
"../assets/img/ultimate/ultimate_10.png",
|
||||||
|
"../assets/img/ultimate/ultimate_20.png",
|
||||||
|
"../assets/img/ultimate/ultimate_30.png",
|
||||||
|
"../assets/img/ultimate/ultimate_40.png",
|
||||||
|
"../assets/img/ultimate/ultimate_50.png",
|
||||||
|
"../assets/img/ultimate/ultimate_60.png",
|
||||||
|
"../assets/img/ultimate/ultimate_70.png",
|
||||||
|
"../assets/img/ultimate/ultimate_80.png",
|
||||||
|
"../assets/img/ultimate/ultimate_90.png",
|
||||||
|
"../assets/img/ultimate/ultimate_100.png"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < 11; ++i) {
|
||||||
|
if (!ultimateIndicatorTextures[i].loadFromFile(texturePaths[i])) {
|
||||||
|
std::cerr << "Failed to load ultimate indicator texture: " << texturePaths[i] << std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
sf::Sprite sprite;
|
||||||
|
sprite.setTexture(ultimateIndicatorTextures[i]);
|
||||||
|
sprite.setPosition(10, window->getSize().y - 60);
|
||||||
|
sprite.setScale(0.7f, 0.7f);
|
||||||
|
ultimateIndicators.push_back(sprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Refactor tej metody bo rozrosła się za bardzo już
|
// TODO: Refactor tej metody bo rozrosła się za bardzo już
|
||||||
void Plansza::update() {
|
void Plansza::update() {
|
||||||
srand(time(0)); // generacja innego ziarna na podstawie zegara systemowego
|
srand(time(0)); // generacja innego ziarna na podstawie zegara systemowego
|
||||||
@@ -105,6 +138,15 @@ void Plansza::update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && !ship->getUltimateStatus() && ultimateCounter >= 200) {
|
||||||
|
ultimateClock.restart();
|
||||||
|
ship->ultimate_shoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
int indicatorIndex = ultimateCounter / 20;
|
||||||
|
indicatorIndex = std::min(indicatorIndex, 10); // Zapobiegaj przekroczeniu zakresu
|
||||||
|
window->draw(ultimateIndicators[indicatorIndex]);
|
||||||
|
|
||||||
// TODO: Przenieść obiekt dźwięku wewnątrz klasy Bullet
|
// TODO: Przenieść obiekt dźwięku wewnątrz klasy Bullet
|
||||||
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
|
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
|
||||||
ship->shoot();
|
ship->shoot();
|
||||||
@@ -122,17 +164,12 @@ void Plansza::update() {
|
|||||||
spawn_hearts();
|
spawn_hearts();
|
||||||
spawn_power_up();
|
spawn_power_up();
|
||||||
spawn_debuff();
|
spawn_debuff();
|
||||||
// spawn_enemy();
|
spawn_enemy();
|
||||||
// spawn_advanced_enemy();
|
spawn_advanced_enemy();
|
||||||
// spawn_wiazkowiec();
|
spawn_wiazkowiec();
|
||||||
// spawn_bomber();
|
spawn_bomber();
|
||||||
// spawn_kamikadze();
|
spawn_kamikadze();
|
||||||
spawn_boss();
|
spawn_boss();
|
||||||
// spawn_enemy();
|
|
||||||
// spawn_advanced_enemy();
|
|
||||||
// spawn_wiazkowiec();
|
|
||||||
// spawn_bomber();
|
|
||||||
// spawn_kamikadze();
|
|
||||||
|
|
||||||
// utrzymanie meteorów i pocisków w ruchu
|
// utrzymanie meteorów i pocisków w ruchu
|
||||||
for (auto &meteor: meteors) {
|
for (auto &meteor: meteors) {
|
||||||
@@ -206,6 +243,8 @@ void Plansza::update() {
|
|||||||
ship->setBulletSpeed(10.0f);
|
ship->setBulletSpeed(10.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleUltimate();
|
||||||
|
|
||||||
if (gameOver) {
|
if (gameOver) {
|
||||||
sf::RenderWindow errorWindow(sf::VideoMode(350, 200), "The end");
|
sf::RenderWindow errorWindow(sf::VideoMode(350, 200), "The end");
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
@@ -946,7 +985,7 @@ void Plansza::spawn_player() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Plansza::spawn_enemy() {
|
void Plansza::spawn_enemy() {
|
||||||
if (enemySpawnClock.getElapsedTime().asSeconds() >= 10) { // Spawn co 10 sekund
|
if (enemySpawnClock.getElapsedTime().asSeconds() >= 3) { // Spawn co 3 sekund
|
||||||
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
||||||
enemies.emplace_back(spawnX, -50, enemyTexture);
|
enemies.emplace_back(spawnX, -50, enemyTexture);
|
||||||
std::cout << "Spawned Basic Enemy at X: " << spawnX << std::endl;
|
std::cout << "Spawned Basic Enemy at X: " << spawnX << std::endl;
|
||||||
@@ -956,7 +995,7 @@ void Plansza::spawn_enemy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Plansza::spawn_advanced_enemy() {
|
void Plansza::spawn_advanced_enemy() {
|
||||||
if (AenemySpawnClock.getElapsedTime().asSeconds() >= 8) { // Spawn co 10 sekund
|
if (AenemySpawnClock.getElapsedTime().asSeconds() >= 5) { // Spawn co 5 sekund
|
||||||
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
||||||
AEnemies.emplace_back(spawnX, -50, advancedEnemyTexture, enemyBulletTexture);
|
AEnemies.emplace_back(spawnX, -50, advancedEnemyTexture, enemyBulletTexture);
|
||||||
std::cout << "Spawned Advanced Enemy at X: " << spawnX << std::endl;
|
std::cout << "Spawned Advanced Enemy at X: " << spawnX << std::endl;
|
||||||
@@ -965,7 +1004,7 @@ void Plansza::spawn_advanced_enemy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Plansza::spawn_bomber() {
|
void Plansza::spawn_bomber() {
|
||||||
if (BomberSpawnClock.getElapsedTime().asSeconds() >= 5) { // Spawn co 10 sekund
|
if (BomberSpawnClock.getElapsedTime().asSeconds() >= 7) { // Spawn co 7 sekund
|
||||||
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
||||||
Bomber bomber(spawnX, -50, BomberEnemyTexture, BombaTexture);
|
Bomber bomber(spawnX, -50, BomberEnemyTexture, BombaTexture);
|
||||||
bomber.setPlanszaHeight(size.height, size.width); // Przekazanie wysokości i szerokości okna
|
bomber.setPlanszaHeight(size.height, size.width); // Przekazanie wysokości i szerokości okna
|
||||||
@@ -976,7 +1015,7 @@ void Plansza::spawn_bomber() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Plansza::spawn_kamikadze() {
|
void Plansza::spawn_kamikadze() {
|
||||||
if (KamikadzeSpawnClock.getElapsedTime().asSeconds() >= 40) { // Spawn co 10 sekund
|
if (KamikadzeSpawnClock.getElapsedTime().asSeconds() >= 9) { // Spawn co 9 sekund
|
||||||
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
||||||
KEnemies.emplace_back(spawnX, -50, KamikadzeTexture);
|
KEnemies.emplace_back(spawnX, -50, KamikadzeTexture);
|
||||||
std::cout << "Spawned Kamikadze Enemy at X: " << spawnX << std::endl;
|
std::cout << "Spawned Kamikadze Enemy at X: " << spawnX << std::endl;
|
||||||
@@ -985,7 +1024,7 @@ void Plansza::spawn_kamikadze() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Plansza::spawn_wiazkowiec() {
|
void Plansza::spawn_wiazkowiec() {
|
||||||
if (WiazkowiecSpawnClock.getElapsedTime().asSeconds() >= 3) { // Spawn co 10 sekund
|
if (WiazkowiecSpawnClock.getElapsedTime().asSeconds() >= 6) { // Spawn co 6 sekund
|
||||||
if (WEnemies.size() < 1) {
|
if (WEnemies.size() < 1) {
|
||||||
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
|
||||||
Wiazkowiec wiazkowiec(spawnX, -50, WiazkowiecTexture, window);
|
Wiazkowiec wiazkowiec(spawnX, -50, WiazkowiecTexture, window);
|
||||||
@@ -998,7 +1037,7 @@ void Plansza::spawn_wiazkowiec() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Plansza::spawn_boss() {
|
void Plansza::spawn_boss() {
|
||||||
if (!bossSpawned && score >= nextBossScoreThreshold) { // Spawn po 60 sekundach
|
if (!bossSpawned && score >= nextBossScoreThreshold) { // Spawn po BossThreshold i jesli go nie ma
|
||||||
boss = new Boss(size.width / 2, -100, BossTexture, enemyBulletTexture, BombaTexture, window);
|
boss = new Boss(size.width / 2, -100, BossTexture, enemyBulletTexture, BombaTexture, window);
|
||||||
boss->setPlanszaHeight(size.width, size.height);
|
boss->setPlanszaHeight(size.width, size.height);
|
||||||
bossSpawned = true;
|
bossSpawned = true;
|
||||||
@@ -1019,6 +1058,10 @@ std::vector<Meteor> &Plansza::getMeteors() {
|
|||||||
void Plansza::update_score() {
|
void Plansza::update_score() {
|
||||||
if (scoreClock.getElapsedTime().asMilliseconds() > 500) {
|
if (scoreClock.getElapsedTime().asMilliseconds() > 500) {
|
||||||
score++;
|
score++;
|
||||||
|
ultimateCounter++;
|
||||||
|
if (ultimateCounter >= 200) {
|
||||||
|
ultimateCounter = 200;
|
||||||
|
}
|
||||||
scoreClock.restart();
|
scoreClock.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1099,3 +1142,30 @@ void Plansza::check_Meteor_collisions() {
|
|||||||
|
|
||||||
ships Plansza::selectedShip = none;
|
ships Plansza::selectedShip = none;
|
||||||
unsigned int Plansza::score = 0;
|
unsigned int Plansza::score = 0;
|
||||||
|
unsigned int Plansza::ultimateCounter = 0;
|
||||||
|
|
||||||
|
void Plansza::handleUltimate() {
|
||||||
|
if (ship->getUltimateStatus() && ultimateCounter >= 200) {
|
||||||
|
float elapsedTime = ultimateClock.getElapsedTime().asSeconds();
|
||||||
|
if (ship->getUltimateStatus() && ultimateClock.getElapsedTime().asSeconds() >= 1) {
|
||||||
|
ultimateCounter = 0;
|
||||||
|
}
|
||||||
|
if (elapsedTime < 1) {
|
||||||
|
sf::RectangleShape ultimateShape(sf::Vector2f(600, 800));
|
||||||
|
int alpha = static_cast<int>(255 * (1 - elapsedTime));
|
||||||
|
ultimateShape.setFillColor(sf::Color(255, 255, 255, alpha));
|
||||||
|
|
||||||
|
meteors.clear();
|
||||||
|
debuffs.clear();
|
||||||
|
enemies.clear();
|
||||||
|
AEnemies.clear();
|
||||||
|
BEnemies.clear();
|
||||||
|
KEnemies.clear();
|
||||||
|
WEnemies.clear();
|
||||||
|
|
||||||
|
window->draw(ultimateShape);
|
||||||
|
} else {
|
||||||
|
ship->setUltimateStatus(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ void Player::alternate_shoot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::ultimate_shoot() {
|
||||||
|
ultimateShootActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::update() {
|
void Player::update() {
|
||||||
// Wyłącz nieśmiertelność po określonym czasie
|
// Wyłącz nieśmiertelność po określonym czasie
|
||||||
if (isImmortal && immortalityClock.getElapsedTime().asSeconds() >= immortalityDuration) {
|
if (isImmortal && immortalityClock.getElapsedTime().asSeconds() >= immortalityDuration) {
|
||||||
@@ -129,3 +133,11 @@ void Player::setBulletSpeed(float speed) {
|
|||||||
|
|
||||||
|
|
||||||
Player* Player::player_ = nullptr;
|
Player* Player::player_ = nullptr;
|
||||||
|
|
||||||
|
bool Player::getUltimateStatus() {
|
||||||
|
return ultimateShootActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setUltimateStatus(bool status) {
|
||||||
|
ultimateShootActive = status;
|
||||||
|
}
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ void Wiazkowiec::takeDamage() {
|
|||||||
if (--hp <= 0) {
|
if (--hp <= 0) {
|
||||||
alive = false;
|
alive = false;
|
||||||
Plansza::score += 10;
|
Plansza::score += 10;
|
||||||
|
Plansza::ultimateCounter += 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||