Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. void Czlowiek::akcja() {
  2. //powieksza wiek!
  3. Zwierze::akcja();
  4. int skok = 1;
  5. if (licznikCzlowiekTurbo > 7) {
  6. skok = 2;
  7. }
  8. else if ((licznikCzlowiekTurbo <= 7) && (licznikCzlowiekTurbo >= 6)) {
  9. skok = rand()%2+1;
  10. }
  11. int nowy_x = this->getX();
  12. int nowy_y = this->getY();
  13. for (int i = 0; i < swiat.organizmy.size(); i++) {
  14. if (((this->getX() == swiat.organizmy[i]->getX()) && ((this->getY() == swiat.organizmy[i]->getY()))) && (this->getIndeks() != swiat.organizmy[i]->getIndeks())) {
  15. kolizja(*swiat.organizmy[i], swiat);
  16. }
  17. }
  18. int klawisz = swiat.getOstatniWcisnietyKlawisz();
  19.  
  20.  
  21. if ((klawisz == Swiat::GORA) && (nowy_y >= 1)) {
  22. nowy_y -= skok;
  23. this->setX(nowy_x);
  24. this->setY(nowy_y);
  25. }
  26. else if ((klawisz == Swiat::DOL) && (nowy_y <= (swiat.getRozmierY() - 2))) {
  27. nowy_y += skok;
  28. this->setX(nowy_x);
  29. this->setY(nowy_y);
  30. }
  31. else if ((klawisz == Swiat::LEWO) && (nowy_x >= 1)) {
  32. nowy_x -= skok;
  33. this->setX(nowy_x);
  34. this->setY(nowy_y);
  35. }
  36. else if ((klawisz == Swiat::PRAWO) && (nowy_x <= (swiat.getRozmiarX() - 2))) {
  37. nowy_x += skok;
  38. this->setX(nowy_x);
  39. this->setY(nowy_y);
  40. }
  41.  
  42.  
  43. if (licznikCzlowiekTurbo > 0) {
  44. licznikCzlowiekTurbo--;
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement