diff options
author | tom <tombarrett@siu.edu> | 2017-01-14 12:10:28 -0600 |
---|---|---|
committer | tom <tombarrett@siu.edu> | 2017-01-14 12:10:28 -0600 |
commit | 92977a889bb045827ae51dc088fa3da501bd29e3 (patch) | |
tree | 84c7981a5169db4758c1caad9f6d449f8da77464 | |
parent | f2f0867edd0d9624a77e4e5db39825b8ea1a55d0 (diff) |
made it so resources spawn during simulation
-rwxr-xr-x | exec | bin | 307904 -> 0 bytes | |||
-rw-r--r-- | inc/constants.hpp | 1 | ||||
-rw-r--r-- | src/list.cpp | 16 |
3 files changed, 11 insertions, 6 deletions
Binary files differ diff --git a/inc/constants.hpp b/inc/constants.hpp index 2a5b8fb..08f548e 100644 --- a/inc/constants.hpp +++ b/inc/constants.hpp @@ -3,6 +3,7 @@ const int CREATURES = 10; const int RESOURCES = 100; +const int MINIMUM_RESOURCES = 90; const int WINDOW_X = 1080; const int WINDOW_Y = 640; diff --git a/src/list.cpp b/src/list.cpp index b8d2888..3127d76 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -2,23 +2,21 @@ List::List(Window m) { - int i; + main = m; + int i; SDL_Rect Rect = {0,0,CREATURE_SIZE,CREATURE_SIZE}; - for(i=0;i<CREATURES;i++){ - Creature X(m,Rect); + Creature X(main,Rect); C.push_back(X); } Rect = {0,0,RESOURCE_SIZE,RESOURCE_SIZE}; - for(i=0;i<RESOURCES;i++){ - Resource Y(m,Rect); + Resource Y(main,Rect); R.push_back(Y); } - main = m; } void List::Place() @@ -50,6 +48,12 @@ void List::Behavior() C.erase(it--); } } + + SDL_Rect Rect = {0,0,RESOURCE_SIZE,RESOURCE_SIZE}; + while(R.size() < MINIMUM_RESOURCES){ + Resource Y(main,Rect); + R.push_back(Y); + } } list<Entity*> List::getNear(Creature nC) |