#include "list.hpp" List::List(Window m) { int i; for(i=0;i::iterator it = C.begin(); it!=C.end(); it++) it->Place(); for(list::iterator it = R.begin(); it!=R.end(); it++){ if(it->getAmount()<=0) R.erase(it--); else it->Place(); } } void List::Behavior() { for(list::iterator it = C.begin(); it!=C.end(); it++){ list N = getNear(*it); it->giveN(N); it->Behavior(); if(it->getHealth()<=0){ Location z = it->getLocation(); SDL_Rect rect = it->getRect(); Resource r = Resource(main,rect.w,z); R.push_back(r); C.erase(it--); } } } list List::getNear(Creature nC) { list N; for(list ::iterator it = R.begin(); it!=R.end(); it++){ if( nC.getBestSense() > Distance(nC.getLocation(),it->getLocation()) ) N.push_back(&(*it)); } for(list ::iterator it = C.begin(); it!=C.end(); it++){ if( &nC == &(*it)) continue; else if( nC.getBestSense() > Distance(nC.getLocation(),it->getLocation()) ) N.push_back(&(*it)); } return N; }