7 Commits

Author SHA1 Message Date
bad49c78a5 Dodane brakujacy plik dzwieku 2025-01-17 20:47:43 +01:00
f5d9bae6e9 Poprawiono ultimate_Png lekko, zmodyfikowano poziom trudnosci 2025-01-17 16:22:36 +01:00
696714cf9a Dodano wiecej progow % 2025-01-16 23:08:03 +01:00
3c0cd4b950 Dodano znaczek ladowania ultimate 2025-01-16 23:01:14 +01:00
bafab8d75a counter fixed at 200 2025-01-16 21:31:34 +01:00
92d5f66a91 ultimate implemented 2025-01-16 21:27:14 +01:00
622e814d1c WIP - ultimate 2025-01-16 20:16:08 +01:00
22 changed files with 127 additions and 26 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
assets/sounds/destroyed.ogg Normal file

Binary file not shown.

View File

@@ -50,6 +50,8 @@ public:
void check_Meteor_collisions();
void check_Debuff_collisions();
void handleUltimate();
void spawn_player();
void spawn_enemy();
void spawn_advanced_enemy();
@@ -64,7 +66,9 @@ public:
static ships selectedShip;
static unsigned int score;
static unsigned int ultimateCounter;
sf::Font font;
private:
Background background;
AudioManager audioManager;
@@ -84,7 +88,7 @@ private:
sf::Clock heartSpawnClock;
sf::Clock powerUpSpawnClock;
sf::Clock debuffSpawnClock;
// sf::Clock spawnClock;
sf::Clock ultimateClock;
sf::Clock scoreClock;
sf::Clock shooterSpawnClock;
sf::Clock enemySpawnClock;
@@ -116,6 +120,7 @@ private:
sf::Texture movingSpeedDebuffTexture;
sf::Texture firerateDebuffTexture;
sf::Texture bulletSpeedDebuffTexture;
sf::Texture ultimateIndicatorTextures[11];
// Tablice
std::vector<Enemy> enemies;
@@ -128,11 +133,14 @@ private:
std::vector<sf::Sprite> heartStats;
std::vector<PowerUp> powerUps;
std::vector<Debuff> debuffs;
std::vector<sf::Sprite> ultimateIndicators;
void loadUltimateIndicators();
// Zmienne prymitywne
Boss* boss = nullptr; // Wskaźnik na 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 gameOver = false;

View File

@@ -22,6 +22,7 @@ public:
void shoot() override;
void alternate_shoot();
void ultimate_shoot();
void setFirerate(unsigned int firerate);
void move(float deltaX, float deltaY) override;
void moveLeft() override;
@@ -30,13 +31,17 @@ public:
void moveDown() override;
void takeDamage();
void setTripleShot(bool toogle);
void setBulletSpeed(float speed);
void setBulletSpeed(float speed);
bool getUltimateStatus();
void update();
std::vector<Rocket>& getRockets();
void loadTexture();
void setUltimateStatus(bool status);
private:
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
std::vector<Rocket> rockets;
@@ -48,6 +53,7 @@ private:
float bulletSpeed = 10.0f; // prędkość pocisku
bool isImmortal = false; // flaga na immortal
bool tripleShot = false; // flaga na potrójny strzał
bool ultimateShootActive = false;
};

View File

@@ -6,7 +6,7 @@ AdvancedEnemy::AdvancedEnemy(int x, int y, const sf::Texture& texture, const sf:
enemyBulletTexture = bulletTexture;
hp = 2; // 2 punkty życia
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");
}
@@ -86,5 +86,6 @@ void AdvancedEnemy::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 10;
Plansza::ultimateCounter += 10;
}
}

View File

@@ -6,8 +6,8 @@
Bomber::Bomber(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture) : Actor(x, y, texture) {
BombaTexture = bulletTexture;
hp = 2; // 2 punkty życia
firerate = 10000; // Strzela co 10
moving_speed = 10.0f; // Prędkość
firerate = 6000; // Strzela co 6
moving_speed = 8.0f; // Prędkość
}
void Bomber::setPlanszaHeight(float height, float width) {
@@ -122,5 +122,6 @@ void Bomber::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 15;
Plansza::ultimateCounter += 15;
}
}

View File

@@ -13,7 +13,7 @@ Boss::Boss(int x, int y, const sf::Texture& bossTexture, const sf::Texture& bull
}
hp = 100;
firerate = 2000;
movementSpeed = 2.0f;
movementSpeed = 3.0f;
}

View File

@@ -5,7 +5,7 @@
Enemy::Enemy(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
hp = 1; // Przeciwnik ma 1 punkt życia
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");
}
@@ -76,5 +76,6 @@ void Enemy::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 5;
Plansza::ultimateCounter += 5;
}
}

View File

@@ -8,7 +8,7 @@
Kamikadze::Kamikadze(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
hp = 3; // 3 punkty życia
moving_speed = 2.0f; // Prędkość
moving_speed = 5.0f; // Prędkość
}
void Kamikadze::shoot(){}
@@ -131,5 +131,6 @@ void Kamikadze::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 20;
Plansza::ultimateCounter += 20;
}
}

View File

@@ -2,6 +2,7 @@
#include <iostream>
#include "../headers/Plansza.h"
#include "../headers/RandomNumberGenerator.h"
#include <SFML/Graphics.hpp>
Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::RenderWindow *mainWindow, ships selectedShip)
: background("../assets/img/background/background.png", 2.0f) {
@@ -46,6 +47,8 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::Render
exit(-500);
}
loadUltimateIndicators();
score = 0;
// 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_alt", "../assets/sounds/shoot_alt.ogg");
audioManager.loadSoundEffect("fail", "../assets/sounds/fail.mp3");
audioManager.loadSoundEffect("destroyed", "../assets/sounds/destroyed.ogg");
heartStats.emplace_back(heartTexture);
heartStats.emplace_back(heartTexture);
@@ -76,6 +80,35 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::Render
// 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ż
void Plansza::update() {
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
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
ship->shoot();
@@ -122,17 +164,12 @@ void Plansza::update() {
spawn_hearts();
spawn_power_up();
spawn_debuff();
// spawn_enemy();
// spawn_advanced_enemy();
// spawn_wiazkowiec();
// spawn_bomber();
// spawn_kamikadze();
spawn_enemy();
spawn_advanced_enemy();
spawn_wiazkowiec();
spawn_bomber();
spawn_kamikadze();
spawn_boss();
// spawn_enemy();
// spawn_advanced_enemy();
// spawn_wiazkowiec();
// spawn_bomber();
// spawn_kamikadze();
// utrzymanie meteorów i pocisków w ruchu
for (auto &meteor: meteors) {
@@ -206,6 +243,8 @@ void Plansza::update() {
ship->setBulletSpeed(10.0f);
}
handleUltimate();
if (gameOver) {
sf::RenderWindow errorWindow(sf::VideoMode(350, 200), "The end");
sf::Font font;
@@ -946,7 +985,7 @@ void Plansza::spawn_player() {
}
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);
enemies.emplace_back(spawnX, -50, enemyTexture);
std::cout << "Spawned Basic Enemy at X: " << spawnX << std::endl;
@@ -956,7 +995,7 @@ void Plansza::spawn_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);
AEnemies.emplace_back(spawnX, -50, advancedEnemyTexture, enemyBulletTexture);
std::cout << "Spawned Advanced Enemy at X: " << spawnX << std::endl;
@@ -965,7 +1004,7 @@ void Plansza::spawn_advanced_enemy() {
}
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);
Bomber bomber(spawnX, -50, BomberEnemyTexture, BombaTexture);
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() {
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);
KEnemies.emplace_back(spawnX, -50, KamikadzeTexture);
std::cout << "Spawned Kamikadze Enemy at X: " << spawnX << std::endl;
@@ -985,7 +1024,7 @@ void Plansza::spawn_kamikadze() {
}
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) {
int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50);
Wiazkowiec wiazkowiec(spawnX, -50, WiazkowiecTexture, window);
@@ -998,7 +1037,7 @@ void Plansza::spawn_wiazkowiec() {
}
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->setPlanszaHeight(size.width, size.height);
bossSpawned = true;
@@ -1019,6 +1058,10 @@ std::vector<Meteor> &Plansza::getMeteors() {
void Plansza::update_score() {
if (scoreClock.getElapsedTime().asMilliseconds() > 500) {
score++;
ultimateCounter++;
if (ultimateCounter >= 200) {
ultimateCounter = 200;
}
scoreClock.restart();
}
@@ -1098,4 +1141,31 @@ void Plansza::check_Meteor_collisions() {
}
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);
}
}
}

View File

@@ -58,6 +58,10 @@ void Player::alternate_shoot() {
}
}
void Player::ultimate_shoot() {
ultimateShootActive = true;
}
void Player::update() {
// Wyłącz nieśmiertelność po określonym czasie
if (isImmortal && immortalityClock.getElapsedTime().asSeconds() >= immortalityDuration) {
@@ -129,3 +133,11 @@ void Player::setBulletSpeed(float speed) {
Player* Player::player_ = nullptr;
bool Player::getUltimateStatus() {
return ultimateShootActive;
}
void Player::setUltimateStatus(bool status) {
ultimateShootActive = status;
}

View File

@@ -200,6 +200,7 @@ void Wiazkowiec::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 10;
Plansza::ultimateCounter += 10;
}
}