diff options
author | tom <tombarrett@siu.edu> | 2017-01-14 11:56:33 -0600 |
---|---|---|
committer | tom <tombarrett@siu.edu> | 2017-01-14 11:56:33 -0600 |
commit | f2f0867edd0d9624a77e4e5db39825b8ea1a55d0 (patch) | |
tree | 1ead1fa412bd7c2e791310c7cb7bbe84c79696a4 /src/list.cpp | |
parent | b97a54b8acd113e99871fdb0f683e27e0912bf42 (diff) |
completly remove location structure and replaced it with sdl_rect
Diffstat (limited to 'src/list.cpp')
-rw-r--r-- | src/list.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/list.cpp b/src/list.cpp index b5e05da..b8d2888 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -4,13 +4,17 @@ List::List(Window m) { int i; + SDL_Rect Rect = {0,0,CREATURE_SIZE,CREATURE_SIZE}; + for(i=0;i<CREATURES;i++){ - Creature X(m,CREATURE_SIZE); + Creature X(m,Rect); C.push_back(X); } + Rect = {0,0,RESOURCE_SIZE,RESOURCE_SIZE}; + for(i=0;i<RESOURCES;i++){ - Resource Y(m,RESOURCE_SIZE); + Resource Y(m,Rect); R.push_back(Y); } @@ -40,9 +44,8 @@ void List::Behavior() it->Behavior(); if(it->getHealth()<=0){ - Location z = it->getLocation(); - SDL_Rect rect = it->getRect(); - Resource r = Resource(main,rect.w,z); + SDL_Rect Rect = it->getRect(); + Resource r = Resource(main,Rect); R.push_back(r); C.erase(it--); } @@ -54,14 +57,14 @@ list<Entity*> List::getNear(Creature nC) list<Entity*> N; for(list <Resource>::iterator it = R.begin(); it!=R.end(); it++){ - if( nC.getBestSense() > Distance(nC.getLocation(),it->getLocation()) ) + if( nC.getBestSense() > Distance(nC.getRect(),it->getRect()) ) N.push_back(&(*it)); } for(list <Creature>::iterator it = C.begin(); it!=C.end(); it++){ if( &nC == &(*it)) continue; - else if( nC.getBestSense() > Distance(nC.getLocation(),it->getLocation()) ) + else if( nC.getBestSense() > Distance(nC.getRect(),it->getRect()) ) N.push_back(&(*it)); } |