aboutsummaryrefslogtreecommitdiffstats
path: root/src/entities.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-10-05 07:31:54 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-10-05 07:31:54 -0400
commit9c7af916fce7252ee0608be8c918b0378249c832 (patch)
tree6ae05fa843fc550ba36677668b7f602df0219119 /src/entities.cpp
parent1e88bc916af1a76e4790bdfcac459bf7ee3e0d48 (diff)
parente58c8920f5332678e4446a8c33bc74a716024010 (diff)
merge
Diffstat (limited to 'src/entities.cpp')
-rw-r--r--src/entities.cpp55
1 files changed, 44 insertions, 11 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 43c7bf3..bd0cc67 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -21,19 +21,50 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o
}
void Entity::draw(void){ //draws the entities
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D,texture);
+ glBegin(GL_QUADS);
if(type==NPCT){
- if(NPCp(this)->aiFunc.size()){
- glColor3ub(255,255,0);
- glRectf(loc.x,loc.y+height+HLINE,loc.x+width,loc.y+height+HLINE*5);
- }
- if(gender == MALE)
- glColor3ub(0,0,100);
- else if(gender == FEMALE)
+ if(gender == MALE){
+ glColor3ub(255,255,255);
+ glTexCoord2i(0,1);glVertex2i(loc.x, loc.y);
+ glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y);
+ glTexCoord2i(1,0);glVertex2i(loc.x + width, loc.y + height);
+ glTexCoord2i(0,0);glVertex2i(loc.x, loc.y + height);
+ }else if(gender == FEMALE){
glColor3ub(255,105,180);
- }else if(type==STRUCTURET){
- glColor3ub(100,0,100);
+ glTexCoord2i(0,1);glVertex2i(loc.x, loc.y);
+ glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y);
+ glTexCoord2i(1,0);glVertex2i(loc.x + width, loc.y + height);
+ glTexCoord2i(0,0);glVertex2i(loc.x, loc.y + height);
+ }
+ }
+ if(type==PLAYERT){
+ if(right==true){
+ glTexCoord2i(0,1);glVertex2i(loc.x, loc.y);
+ glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y);
+ glTexCoord2i(1,0);glVertex2i(loc.x + width, loc.y + height);
+ glTexCoord2i(0,0);glVertex2i(loc.x, loc.y + height);
+ }if(left==true){
+ glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
+ glScalef(-1.0f,1.0f,1.0f);
+ glTexCoord2i(0,1);glVertex2i(loc.x, loc.y);
+ glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y);
+ glTexCoord2i(1,0);glVertex2i(loc.x + width, loc.y + height);
+ glTexCoord2i(0,-0);glVertex2i(loc.x, loc.y + height);
+ }
+
+ }else{
+ glTexCoord2i(0,1);glVertex2i(loc.x, loc.y);
+ glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y);
+ glTexCoord2i(1,0);glVertex2i(loc.x + width, loc.y + height);
+ glTexCoord2i(0,0);glVertex2i(loc.x, loc.y + height);
}
- glRectf(loc.x,loc.y,loc.x+width,loc.y+height);
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
+ glMatrixMode(GL_MODELVIEW);
if(near){
ui::setFontSize(14);
ui::putText(loc.x,loc.y-ui::fontSize-HLINE/2,"%s",name);
@@ -93,6 +124,7 @@ Player::Player(){ //sets all of the player specific traits on object creation
alive = true;
ground = false;
near = true;
+ texture = loadTexture("assets/player.png");
inv = new Inventory(PLAYER_INV_SIZE);
}
@@ -109,6 +141,7 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation
alive = true;
canMove = true;
near = false;
+ texture = loadTexture("assets/NPC.png");
inv = new Inventory(NPC_INV_SIZE);
}
@@ -145,7 +178,7 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure
if(type == STRUCTURET){
loc.y=100;
width = 20 * HLINE;
- height = 16 * HLINE;
+ height = 20 * HLINE;
int tempN = (getRand() % 5 + 2); //amount of villagers that will spawn
for(int i=0;i<tempN;i++){