]> khamidou — GitHub mirrors - Bug_Attack.git/commitdiff
ajouté un itérateur
authorkhamidou <khamidou@gmail.com>
Sat, 28 May 2011 15:10:44 +0000 (17:10 +0200)
committerkhamidou <khamidou@gmail.com>
Sat, 28 May 2011 15:10:44 +0000 (17:10 +0200)
projectile.cpp

index d16df67078b481612799565c6faf8c97184fff57..c4d3b118f492506071ea02ee8a87772fa02c40d8 100644 (file)
@@ -37,13 +37,14 @@ void Projectile::advance(int phase) {
     // Collision avec ennemi
     // . Recherche des ennemis de la map
     QList<Enemy*> entities = _map->getEnemyList();
-
-    for(int i = 0 ; i < entities.length() ; ++i) {
-            if(this->collidesWithItem(entities[i],Qt::IntersectsItemBoundingRect)){
+    QList<Enemy*>::iterator i;
+    for(i = entities.begin(); i < entities.end() ; ++i) {
+            if(this->collidesWithItem(*i,Qt::IntersectsItemBoundingRect)){
                 // On retire le projectile de la scène
                 this->scene()->removeItem(this);
                 // Inflige des dommages au monstre
-                entities[i]->hurt(_damages);
+                Enemy *e = *i;
+                e->hurt(_damages);
                 return;
             }
     }