Advertisement
Guest User

Untitled

a guest
May 21st, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define length 10
  5.  
  6. int main() {
  7. //strzal dolatuje natychmiastowo
  8. int win = 0;
  9. int objectPositionX = 0;
  10. int cannonPositionX = length/2;
  11. char choice;
  12. int shoots = 0;
  13.  
  14. while(win != 1) {
  15. objectPositionX++;
  16. printf("strzel(spacja) lub zaczekaj(w)\n");
  17. scanf("%c", &choice);
  18. if(choice == ' ') {
  19. shoots++;
  20. if(cannonPositionX == objectPositionX) {
  21. win = 1;
  22. printf("zestrzeliles obiekt, wygrana!");
  23. } else {
  24. printf("pudlo!");
  25. }
  26. } else {
  27. printf("odczekano kolejke");
  28. }
  29. if(objectPositionX == length) {
  30. printf("obiekt uciekl, przygotuj sie na kolejny");
  31. objectPositionX = 0;
  32. }
  33. }
  34. printf("oddales %d strzalow", shoots);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement