From b97a54b8acd113e99871fdb0f683e27e0912bf42 Mon Sep 17 00:00:00 2001 From: tom Date: Wed, 11 Jan 2017 02:19:07 -0600 Subject: -removed all magic numbers and placed them in a constants header -removed unused libraries and redid all header files --- src/creature.cpp | 8 ++++---- src/entity.cpp | 8 ++++---- src/list.cpp | 8 ++++---- src/resource.cpp | 4 ++-- src/window.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/creature.cpp b/src/creature.cpp index 7e9011a..b81153e 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -10,8 +10,8 @@ Creature::Creature(Window m, int size) L.x = rect.x; L.y = rect.y; - health = 500; - maxHealth = 1000; + health = CREATURE_START_HEALTH; + maxHealth = CREATURE_MAX_HEALTH; hungry = false; hasTarget = false; @@ -61,7 +61,7 @@ void Creature::setTarget() if(!hasTarget&&!wander){ wander = true; - wTarget = Location(rand()%1200,rand()%800); + wTarget = Location(rand()%WINDOW_X,rand()%WINDOW_Y); } } @@ -69,7 +69,7 @@ void Creature::setTarget() void Creature::Action() { if(hasTarget){ - if(Distance(L,target->getLocation())<5){ + if(Distance(L,target->getLocation())eat(); health+=10; } diff --git a/src/entity.cpp b/src/entity.cpp index be3e792..ff6799e 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -3,8 +3,8 @@ void Entity::Init(Window m) { renderer = m.getRenderer(); - rect.y = rand()%640; - rect.x = rand()%1080; + rect.y = rand()%WINDOW_Y; + rect.x = rand()%WINDOW_X; } void Entity::Init(Window m, Location z) @@ -21,7 +21,7 @@ void Entity::Place() else SDL_SetRenderDrawColor(renderer,0,255,0,255); - SDL_RenderDrawRect(renderer, &rect); + SDL_RenderFillRect(renderer, &rect); - SDL_SetRenderDrawColor(renderer,0,0,0,255); + SDL_SetRenderDrawColor(renderer,0,0,0,0); } diff --git a/src/list.cpp b/src/list.cpp index 2fca4f4..b5e05da 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -4,13 +4,13 @@ List::List(Window m) { int i; - for(i=0;i<10;i++){ - Creature X(m,10); + for(i=0;i