Advertisement
azizkhelifi

joystick P2

Dec 27th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1.         if ( Joystick::isButtonPressed(0,0) )
  2.         {
  3.             P2.move(0.0, -5 * speed);
  4.                 P2.setTexture(TP2u);
  5.                 std::cout << " 0 " << std::endl;
  6.                 for (int i = 0; i < n; i++)
  7.                 {
  8.                     if (P2.getGlobalBounds().intersects(obs[i].getGlobalBounds()))
  9.                         P2.move(0.0, +5 * speed);
  10.                 }
  11.             for (int i = 0; i < f; i++)
  12.             {
  13.                 if (P2.getGlobalBounds().intersects(box[i].getGlobalBounds()))
  14.                 {
  15.                     P2.move(0.0, +5 * speed);
  16.                     if (P2timer.asSeconds() >= 1)
  17.                     {
  18.                         if (Joystick::isButtonPressed(0, 6))
  19.                         {
  20.                             std::cout << " 8 " << std::endl;
  21.                             box[i].setPosition(-51, 0);
  22.                             P2timer = clock2.restart();
  23.  
  24.                         }
  25.                     }
  26.  
  27.                 }
  28.             }
  29.         }
  30.  
  31.         if (Joystick::isButtonPressed(0, 2) ){
  32.             P2.move(0.0, 5 * speed);
  33.             P2.setTexture(TP2d);
  34.             for (int i = 0; i < n; i++)
  35.             {
  36.                 if (P2.getGlobalBounds().intersects(obs[i].getGlobalBounds()))
  37.                     P2.move(0.0, -5 * speed);
  38.             }
  39.             for (int i = 0; i < f; i++)
  40.             {
  41.                 if (P2.getGlobalBounds().intersects(box[i].getGlobalBounds()))
  42.                 {
  43.                     P2.move(0.0, -5 * speed);
  44.                     if (P2timer.asSeconds() >= 1)
  45.                     {
  46.                         if (Joystick::isButtonPressed(0, 6))
  47.                         {
  48.                             box[i].setPosition(-51, 0);
  49.                             P2timer = clock2.restart();
  50.  
  51.                         }
  52.                     }
  53.                 }
  54.             }
  55.         }
  56.    
  57.  
  58.  
  59.         if (Joystick::isButtonPressed(0, 3)) {
  60.             P2.move(-5 * speed, 0.0);
  61.             P2.setTexture(TP2l);
  62.             for (int i = 0; i < n; i++)
  63.             {
  64.                 if (P2.getGlobalBounds().intersects(obs[i].getGlobalBounds()))
  65.                     P2.move(5 * speed, 0.0);
  66.             }
  67.             for (int i = 0; i < f; i++)
  68.             {
  69.                 if (P2.getGlobalBounds().intersects(box[i].getGlobalBounds()))
  70.                 {
  71.                     P2.move(5 * speed, 0.0);
  72.                     if (P2timer.asSeconds() >= 1)
  73.                     {
  74.                         if (Joystick::isButtonPressed(0, 6))
  75.                         {
  76.                             box[i].setPosition(-51, 0);
  77.                             P2timer = clock2.restart();
  78.  
  79.                         }
  80.  
  81.                     }
  82.                 }
  83.  
  84.             }
  85.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement