diff options
author | iamn1ck <iamn1ck@yahoo.com> | 2017-02-19 07:00:34 -0600 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-03-07 13:22:46 -0600 |
commit | 74c6854fd8dcbaee736ac0421805ff1e03c4a1e2 (patch) | |
tree | 4a3ae40bea9b07a2111128e98d9272bdbac2af87 /src/resource.cpp | |
parent | 03885192b9ff7d3c5e2dcfd98aefd21e9b62f603 (diff) |
-quadtree and opengl rendering are now in the master branch !
-using sdl_rect for location and size ended up being not so great due to it not having floats, so we reverted back to using location
-much, much refractoring is now needed
Diffstat (limited to 'src/resource.cpp')
-rw-r--r-- | src/resource.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/resource.cpp b/src/resource.cpp index ee9100a..31811ca 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -1,15 +1,21 @@ #include "resource.hpp" -Resource::Resource(Window M, SDL_Rect R) +Resource::Resource(Location t) { - renderer = M.getRenderer(); - rect = R; + L = t; - if(rect.x == 0 && rect.y == 0){ - rect.x = rand()%WINDOW_X; - rect.y = rand()%WINDOW_Y; + if(L.x == 0 && L.y == 0){ + L.x = -30 + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(30.0-(-30.0)))); + L.y = -30 + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(30.0-(-30.0)))); } + gfxData.x = L.x; + gfxData.y = L.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; @@ -24,6 +30,6 @@ void Resource::grow() { if(amount < RESOURCE_AMOUNT_MAX){ amount+=growAmount; - rect.h = rect.w = map(amount,0,RESOURCE_AMOUNT_MAX,0,RESOURCE_SIZE_MAX); + L.h = L.w = map(amount,0,RESOURCE_AMOUNT_MAX,0,RESOURCE_SIZE_MAX); } } |