diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-10-07 08:40:43 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-10-07 08:40:43 -0400 |
commit | 40efc2db79c205d122ca9557c9cd0d5679a37446 (patch) | |
tree | d6a227b598ca890de6ecf566a2c6dd2350d17e74 /src/entities.cpp | |
parent | f28fda996331de5dac8fc2f20ea0898527239fe5 (diff) | |
parent | aad308a8938135a9fd2614f2cf47774918539847 (diff) |
world improvement
Diffstat (limited to 'src/entities.cpp')
-rw-r--r-- | src/entities.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index 49fce0f..13c042b 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -42,7 +42,33 @@ void Entity::draw(void){ //draws the entities glMatrixMode(GL_TEXTURE); glLoadIdentity(); glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D,texture); + if(type == PLAYERT){ + static int texState = 0; + static bool up = true; + if(loops % (int)((float)5 / (float)speed) == 0){ + if(up){ + texState+=1; + if(texState==2)up=false; + }else if(!up){ + texState-=1; + if(texState==0)up=true; + } + }if(vel.x != 0){ + switch(texState){ + case 0: + glBindTexture(GL_TEXTURE_2D,texture[1]); + break; + case 1: + glBindTexture(GL_TEXTURE_2D,texture[0]); + break; + case 2: + glBindTexture(GL_TEXTURE_2D,texture[2]); + break; + } + }else glBindTexture(GL_TEXTURE_2D,texture[0]); + }else{ + glBindTexture(GL_TEXTURE_2D,texture[0]); + } glBegin(GL_QUADS); glTexCoord2i(0,1);glVertex2i(loc.x, loc.y); glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y); @@ -111,7 +137,9 @@ Player::Player(){ //sets all of the player specific traits on object creation alive = true; ground = false; near = true; - texture = loadTexture("assets/player.png"); + texture[0] = loadTexture("assets/player.png"); + texture[1] = loadTexture("assets/player1.png"); + texture[2] = loadTexture("assets/player2.png"); inv = new Inventory(PLAYER_INV_SIZE); } @@ -128,7 +156,9 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation alive = true; canMove = true; near = false; - texture = loadTexture("assets/NPC.png"); + texture[0] = loadTexture("assets/NPC.png"); + texture[1] = 0; + texture[2] = 0; inv = new Inventory(NPC_INV_SIZE); } @@ -152,7 +182,9 @@ Structures::Structures(){ //sets the structure type speed = 0; alive = true; near = false; - texture = loadTexture("assets/house1.png"); + texture[0] = loadTexture("assets/house1.png"); + texture[1] = 0; + texture[2] = 0; } unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure based off of type and coords |