From 5f67a8d195527cd6948f5d0aaee5deb5ac34f8df Mon Sep 17 00:00:00 2001 From: cboissie Date: Sun, 22 May 2011 04:29:30 +0200 Subject: [PATCH] - Still wip (don't use right click on UNIX) --- enemy.cpp | 13 +------------ enemy.h | 1 - enemyfactory.h | 1 + map.cpp | 7 ++++--- map.h | 2 -- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/enemy.cpp b/enemy.cpp index 437974a..428620f 100644 --- a/enemy.cpp +++ b/enemy.cpp @@ -19,19 +19,17 @@ bool Enemy::isDestroyed(void) const { return _destroyed; } float Enemy::getSize(void) const { return _size; } void Enemy::hurt(int damages){ + // Inflige 'damages' dégats à l'ennemi _hp-=damages; // Si ses HP sont tombés à zéro, on le détruit if(_hp <= 0) { // Indique que la mort est provoquée par le joueur emit killedByPlayer(this->getResistance()); // TODO choisir le gain - this->scene()->removeItem(this); // Retire de l'indexation de la map _destroyed = true; emit enemyDestroyed(); - - } std::cout << "ahah il me reste : " << _hp << " HP" << std::endl; @@ -107,12 +105,3 @@ void Cafard::advance(int phase) { else if(dirVect.y() == -1) this->setRotation(-90); } - -// Un cafard se sous divise en deux cafard si sa taille est -// supérieure ou égale à deux -Cafard::~Cafard(void) { - - if(_size<2) - return; - -} diff --git a/enemy.h b/enemy.h index a6e6768..6f35177 100644 --- a/enemy.h +++ b/enemy.h @@ -49,7 +49,6 @@ class Cafard : public Enemy public: Cafard(Map* map,int posx,int posy, float size); - ~Cafard(void); protected: void advance(int phase); diff --git a/enemyfactory.h b/enemyfactory.h index c137a80..eaacee9 100644 --- a/enemyfactory.h +++ b/enemyfactory.h @@ -40,6 +40,7 @@ public: WaveElement* popNextWaveElement(void); bool isFinished(void) const; QString getDesc(void) const; + QMutex mutex; }; class EnemyFactory : public QObject diff --git a/map.cpp b/map.cpp index 5ec7fe1..03ff441 100644 --- a/map.cpp +++ b/map.cpp @@ -70,15 +70,16 @@ void Map::addEnemy(Enemy *enemy) { void Map::removeEnemy(void) { // Garbage collector de notre liste - std::cout << "c'est l'heure du nettoyage" << std::endl; QList::iterator i; for(i = _enemies.begin() ; i != _enemies.end() ; ++i) { - if((*i)->isDestroyed()) + + if((*i)->isDestroyed()){ + this->removeItem((*i)); _enemies.erase(i); std::cout << "OMG un mort" << std::endl; + } } - } QList Map::getEnemyList(void) const { return _enemies; }; diff --git a/map.h b/map.h index d90d180..113bd32 100644 --- a/map.h +++ b/map.h @@ -1,8 +1,6 @@ #ifndef MAP_H #define MAP_H - - #include #include #include -- 2.43.0