Advertisement
Astaa001

Untitled

Apr 21st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.63 KB | None | 0 0
  1. if ((Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)) {
  2.             monster1.move(speed, 0.0);
  3.             time = clock.getElapsedTime();
  4.             if (time.asSeconds() >= 0.1) {
  5.                 clock.restart();
  6.                 p++;
  7.                 if (p > 8)
  8.                     p -= 8;
  9.             }
  10.             monster1.setTextureRect(IntRect(monster1_size.x*p, monster1_size.y * 3, monster1_size.x, monster1_size.y));
  11.  
  12.             /*if (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2) {
  13.                 flag = 0;
  14.             }
  15.             if (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2) {
  16.                 flag = 0;
  17.             }*/
  18.  
  19.         }
  20.         else if (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)           // Moving Up
  21.         {
  22.             monster1.move(0.0, -speed);
  23.             time = clock.getElapsedTime();
  24.             if (time.asSeconds() >= 0.1) {
  25.                 clock.restart();
  26.                 p++;
  27.                 if (p > 8)
  28.                     p -= 8;
  29.             }
  30.             monster1.setTextureRect(IntRect(monster1_size.x*p, monster1_size.y * 0, monster1_size.x, monster1_size.y));
  31.             /*if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2) {
  32.                 flag = 1;
  33.             }
  34.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2) {
  35.                 flag = 1;
  36.             }*/
  37.  
  38.  
  39.         }
  40.         else if (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)         // Moving Down
  41.         {
  42.             monster1.move(0.0, speed);
  43.             time = clock.getElapsedTime();
  44.             if (time.asSeconds() >= 0.1) {
  45.                 clock.restart();
  46.                 p++;
  47.                 if (p > 8)
  48.                     p -= 8;
  49.             }
  50.             monster1.setTextureRect(IntRect(monster1_size.x*p, monster1_size.y * 2, monster1_size.x, monster1_size.y));
  51.             /*if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2) {
  52.                 flag = 1;
  53.             }
  54.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2) {
  55.                 flag = 1;
  56.             }*/
  57.  
  58.  
  59.         }
  60.  
  61.         else if ((Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  62.         {
  63.             monster1.move(-speed, 0.0);
  64.             time = clock.getElapsedTime();
  65.             if (time.asSeconds() >= 0.1) {
  66.                 clock.restart();
  67.                 p++;
  68.                 if (p > 8)
  69.                     p -= 8;
  70.             }
  71.             monster1.setTextureRect(IntRect(monster1_size.x*p, monster1_size.y * 1, monster1_size.x, monster1_size.y));
  72.  
  73.             /*if (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2) {
  74.                 flag = 0;
  75.             }
  76.             if (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2) {
  77.                 flag = 0;
  78.             }*/
  79.  
  80.         }
  81.  
  82.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement