summaryrefslogtreecommitdiff
path: root/src/resource.cpp
diff options
context:
space:
mode:
authormajortom6 <tombarrett@siu.edu>2017-02-19 12:00:52 -0600
committerTom Barrett <tombarrett@siu.edu>2017-03-07 13:23:41 -0600
commit0846d5802965d257f176e033d7a6ac353ed648f3 (patch)
tree1ada2e260970883decd2165d3dd3b74ad34212fd /src/resource.cpp
parentbfdc713b68dd6f8d61e7b26fc2cff15caf24b44d (diff)
-speedcaps now working again
-creatures now randomize target better again -thats enough for today, src is still a mess and main can be cleaned a bit
Diffstat (limited to 'src/resource.cpp')
-rw-r--r--src/resource.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/resource.cpp b/src/resource.cpp
index 9933c4f..81fd6b7 100644
--- a/src/resource.cpp
+++ b/src/resource.cpp
@@ -2,23 +2,23 @@
Resource::Resource(Rectangle t)
{
- rect = t;
-
- if(rect.x == 0 && rect.y == 0){
- rect.x = -30 + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(30.0-(-30.0))));
- rect.y = -30 + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(30.0-(-30.0))));
- }
+ rect = t;
- gfxData.x = rect.x;
- gfxData.y = rect.y;
- gfxData.r = 0.0;
- gfxData.g = 1.0;
- gfxData.b = 0.0;
- gfxData.sides = 10.0;
+ if(rect.x == 0 && rect.y == 0){
+ rect.x = getRandom(50);
+ rect.y = getRandom(50);
+ }
- type = RESOURCE_TYPE;
- amount = RESOURCE_AMOUNT_START;
- growAmount = RESOURCE_GROW;
+ gfxData.x = rect.x;
+ gfxData.y = rect.y;
+ gfxData.r = 0.0;
+ gfxData.g = 1.0;
+ gfxData.b = 0.0;
+ gfxData.sides = 10.0;
+
+ type = RESOURCE_TYPE;
+ amount = RESOURCE_AMOUNT_START;
+ growAmount = RESOURCE_GROW;
}
void Resource::eat(int bite)
@@ -28,8 +28,8 @@ void Resource::eat(int bite)
void Resource::grow()
{
- if(amount < RESOURCE_AMOUNT_MAX){
- amount+=growAmount;
- rect.h = rect.w = map(amount,0,RESOURCE_AMOUNT_MAX,0,RESOURCE_SIZE_MAX);
- }
+ if(amount < RESOURCE_AMOUNT_MAX){
+ amount+=growAmount;
+ rect.h = rect.w = map(amount,0,RESOURCE_AMOUNT_MAX,0,RESOURCE_SIZE_MAX);
+ }
}