6 Commits

20 changed files with 61 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.25)
project(LotoStatek)
include(FetchContent)
set(CMAKE_CXX_STANDARD 17)
add_executable(LotoStatek main.cpp
@@ -63,9 +63,12 @@ if(WIN32)
target_link_libraries(LotoStatek ${SFML_LIBRARIES})
endif()
elseif(APPLE)
find_package(SFML 2.6.2 COMPONENTS graphics window system REQUIRED)
target_link_libraries(LotoStatek sfml-graphics sfml-window sfml-audio sfml-system)
elseif(LINUX)
find_package(SFML 2.6.2 COMPONENTS graphics window system REQUIRED)
set(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(
SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.2
)
FetchContent_MakeAvailable(SFML)
target_link_libraries(LotoStatek sfml-graphics sfml-window sfml-audio sfml-system)
endif()

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

@@ -120,6 +120,7 @@ private:
sf::Texture movingSpeedDebuffTexture;
sf::Texture firerateDebuffTexture;
sf::Texture bulletSpeedDebuffTexture;
sf::Texture ultimateIndicatorTextures[11];
// Tablice
std::vector<Enemy> enemies;
@@ -132,6 +133,9 @@ 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

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");
}

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) {

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");
}

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(){}

View File

@@ -47,6 +47,8 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::Render
exit(-500);
}
loadUltimateIndicators();
score = 0;
// Wczytywanie czcionki dla licznika punktów
@@ -61,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);
@@ -77,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
@@ -111,6 +143,10 @@ void Plansza::update() {
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();
@@ -133,7 +169,7 @@ void Plansza::update() {
spawn_wiazkowiec();
spawn_bomber();
spawn_kamikadze();
// spawn_boss();
spawn_boss();
// utrzymanie meteorów i pocisków w ruchu
for (auto &meteor: meteors) {
@@ -181,7 +217,6 @@ void Plansza::update() {
check_Debuff_collisions();
// TODO: Dodać flagę aby warunek był sprawdzany nie tylko pod kątem Timeru ale również pod kątem ustawionej flagi
if (movingSpeedPUTimer.getElapsedTime().asSeconds() >= 5.0f && powerUpCollected.movingSpeed) {
powerUpCollected.movingSpeed = false;
ship->setMovingSpeed(8.0f);
@@ -949,7 +984,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;
@@ -959,7 +994,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;
@@ -968,7 +1003,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
@@ -979,7 +1014,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;
@@ -988,7 +1023,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);
@@ -1001,7 +1036,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;