]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Added walking animation to player
authordrumsetmonkey <abelleisle@roadrunner.com>
Wed, 7 Oct 2015 12:38:50 +0000 (08:38 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Wed, 7 Oct 2015 12:38:50 +0000 (08:38 -0400)
1  2 
main.cpp
out/entities.o
src/entities.cpp

diff --cc main.cpp
index c11da6d692e7ba2f70a36f630c3549b9ff5eba1e,e1b8d3d02f9edf1d5461ceedc25604fc45bdc147..5834310737f27bec07dbc0d471d48f0703e82391
+++ b/main.cpp
@@@ -234,6 -234,4 +234,5 @@@ void logic()
                        }
                }
        }
-       //std::cout << loops << std::endl;
 +      loops++;
  }
diff --cc out/entities.o
index 2fe8908f8110849e307ada20c368f41cc9558744,0000000000000000000000000000000000000000..db0a4aab8802f40f7f7fe1390247f907a4f626d0
mode 100644,000000..100644
Binary files differ
index 197bea01d118addaf2307e778c4c590619a31fbb,46d445b19b5ef8ca43566104f39555c7b308c661..0ca228484192571384e9750cc376dc29bbcf07cb
@@@ -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);