diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-01-19 07:33:46 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-01-19 07:33:46 -0500 |
commit | fbd4ddbab2cc3a713430483b24642cbbc7050f0c (patch) | |
tree | 4fa2c7875240621b17f0dcf74d67066190dd7445 /include | |
parent | 1eced16d75322832617a1b42ec94580a9713e8f0 (diff) |
Stuff
Diffstat (limited to 'include')
-rw-r--r-- | include/Texture.h | 2 | ||||
-rw-r--r-- | include/common.h | 14 | ||||
-rw-r--r-- | include/entities.h | 21 |
3 files changed, 33 insertions, 4 deletions
diff --git a/include/Texture.h b/include/Texture.h index 85225d8..7160d37 100644 --- a/include/Texture.h +++ b/include/Texture.h @@ -28,6 +28,8 @@ namespace Texture{ */ GLuint loadTexture(const char *fileName); + void initColorIndex(); + vec2 getIndex(Color c); } /** diff --git a/include/common.h b/include/common.h index ae832f1..f5952eb 100644 --- a/include/common.h +++ b/include/common.h @@ -30,14 +30,22 @@ typedef unsigned int uint; #undef near #endif -#include <Texture.h> - /** * This flag lets the compiler know that we want to use shaders. */ #define SHADERS +template<typename N> +N abso(N v){ + if(v < 0.0){ + return v * -1; + }else + return v; +} + +extern GLuint colorIndex; + /** * This structure contains a set of coordinates for ease of coding. */ @@ -68,6 +76,8 @@ typedef struct{ float blue; } Color; +#include <Texture.h> + /** * Define the game's name (displayed in the window title). */ diff --git a/include/entities.h b/include/entities.h index d434546..51032ef 100644 --- a/include/entities.h +++ b/include/entities.h @@ -57,6 +57,8 @@ public: float velx; float vely; Color color; + vec2 index; + //GLuint tex; float duration; bool canMove; bool fountain; @@ -76,13 +78,26 @@ public: fountain = false; gravity = true; behind = false; + index = Texture::getIndex(c); + //tex = text; } ~Particles(){ } void draw(){ - glColor3f(color.red,color.green,color.blue); - glRectf(loc.x,loc.y,loc.x+width,loc.y+height); + //glColor3f(color.red,color.green,color.blue); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, colorIndex); + glEnable(GL_TEXTURE_2D); + glColor3ub(255,255,255); + glBegin(GL_QUADS); + glTexCoord2f(.25*index.x, .125*(index.y + 1)); glVertex2i(loc.x, loc.y); + glTexCoord2f(.25*(index.x+1), .125*(index.y + 1)); glVertex2i(loc.x + width, loc.y); + glTexCoord2f(.25*(index.x+1), .125*index.y); glVertex2i(loc.x + width, loc.y + height); + glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y + width); + glEnd(); + glDisable(GL_TEXTURE_2D); + //glRectf(loc.x,loc.y,loc.x+width,loc.y+height); } bool kill(float delta){ duration -= delta; @@ -93,6 +108,8 @@ public: } }; +void initEntity(); + class Entity{ public: Inventory *inv; |