Implementacja naliczania punktów za zabicie wrogów
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();) {
|
||||
@@ -816,3 +817,4 @@ void Plansza::update_score() {
|
||||
}
|
||||
|
||||
ships Plansza::selectedShip = none;
|
||||
unsigned int Plansza::score = 0;
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user