From: drumsetmonkey Date: Wed, 7 Oct 2015 12:38:50 +0000 (-0400) Subject: Added walking animation to player X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=aad308a8938135a9fd2614f2cf47774918539847;p=clyne%2Fgamedev.git Added walking animation to player --- aad308a8938135a9fd2614f2cf47774918539847 diff --cc main.cpp index c11da6d,e1b8d3d..5834310 --- a/main.cpp +++ b/main.cpp @@@ -234,6 -234,4 +234,5 @@@ void logic() } } } + loops++; - //std::cout << loops << std::endl; } diff --cc out/entities.o index 2fe8908,0000000..db0a4aa mode 100644,000000..100644 Binary files differ diff --cc src/entities.cpp index 197bea0,46d445b..0ca2284 --- a/src/entities.cpp +++ b/src/entities.cpp @@@ -42,35 -42,7 +42,33 @@@ void Entity::draw(void){ //draws the e 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; + } - } - std::cout << texState << std::endl; - if(vel.x != 0){ ++ }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);