Implementacja naliczania punktów za zabicie wrogów

This commit is contained in:
2024-12-14 20:32:08 +01:00
parent 9432cd94fe
commit 94eddb457f
7 changed files with 18 additions and 7 deletions

View File

@@ -46,6 +46,7 @@ public:
}
static ships selectedShip;
static unsigned int score;
private:
Background background;
AudioManager audioManager;
@@ -87,7 +88,6 @@ private:
std::vector<Heart> hearts;
std::vector<sf::Sprite> heartStats;
bool gameOver = false;
unsigned int score = 0;
};
#endif //PLANSZA_H

View File

@@ -1,5 +1,6 @@
#include "../headers/AdvancedEnemy.h"
#include "../headers/Bullet.h"
#include "../headers/Plansza.h"
AdvancedEnemy::AdvancedEnemy(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture) : Actor(x, y, texture) {
actorSprite.setTexture(texture);
@@ -85,5 +86,6 @@ bool AdvancedEnemy::isAlive() const {
void AdvancedEnemy::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 10;
}
}

View File

@@ -1,5 +1,6 @@
#include "../headers/Bomber.h"
#include "../headers/Bullet.h"
#include "../headers/Plansza.h"
#include <random>
Bomber::Bomber(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture) : Actor(x, y, texture) {
@@ -121,5 +122,6 @@ bool Bomber::isAlive() const {
void Bomber::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 15;
}
}

View File

@@ -1,5 +1,6 @@
#include "../headers/Enemy.h"
#include "../headers/Bullet.h"
#include "../headers/Plansza.h"
Enemy::Enemy(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
actorSprite.setTexture(texture);
@@ -75,5 +76,6 @@ bool Enemy::isAlive() const {
void Enemy::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 5;
}
}

View File

@@ -1,9 +1,10 @@
#include "../headers/Kamikadze.h"
#include <iostream>
#include <random>
#include "../headers/Kamikadze.h"
#include "../headers/RandomNumberGenerator.h"
#include "../headers/Plansza.h"
Kamikadze::Kamikadze(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) {
actorSprite.setTexture(texture);
@@ -130,5 +131,6 @@ bool Kamikadze::isAlive() const {
void Kamikadze::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 20;
}
}

View File

@@ -455,6 +455,7 @@ void Plansza::update() {
wiazkowiec.render(*window);
}
// TODO: naprawić to co średnio działa
// Usuwanie pocisków, które są poza ekranem srednio to dziala
for (auto enemyIt = enemies.begin(); enemyIt != enemies.end();) {
for (auto bulletIt = enemyIt->getBullets().begin(); bulletIt != enemyIt->getBullets().end();) {
@@ -815,4 +816,5 @@ void Plansza::update_score() {
window->draw(text);
}
ships Plansza::selectedShip = none;
ships Plansza::selectedShip = none;
unsigned int Plansza::score = 0;

View File

@@ -1,9 +1,9 @@
#include "../headers/Wiazkowiec.h"
#include <iostream>
#include "../headers/Bullet.h"
#include <random>
#include "../headers/Plansza.h"
Wiazkowiec::Wiazkowiec(int x, int y, const sf::Texture& texture) : Actor(x, y, texture), beam(0, 0, 50.f, 50.f, sf::Color::Red) {
actorSprite.setTexture(texture);
@@ -176,6 +176,7 @@ bool Wiazkowiec::isAlive() const {
void Wiazkowiec::takeDamage() {
if (--hp <= 0) {
alive = false;
Plansza::score += 10;
}
}