Advertisement
Guest User

Untitled

a guest
Apr 21st, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.22 KB | None | 0 0
  1. Shoot(burstsCount, roundsCount)
  2. {
  3.     for (i = 0; i < burstsCount; i++) // do it burstsCount times
  4.     {
  5.         DrawBullet(sightX, sightY);
  6.         for (k = 0; k < roundsCount; k++) // do it roundsCount times
  7.         {
  8.             ShootBullet();
  9.         }
  10.         Centre(); // set to centre after each burst
  11.     }
  12. }
  13.  
  14. ShootBullet()
  15. {
  16.     Kick();
  17.     Recovery();
  18.     AddCompensation();
  19. }
  20.  
  21. // this function kicks sight to random point
  22. Kick()
  23. {
  24.     // random(a, b) returns random number between a and b
  25.     // random(-10, 20) can return -7, 5, 7, 19, -2 etc
  26.     sightX = sightX + random(Xmin, Xmax);
  27.     sightY = sightY + random(Ymin, Ymax);
  28. }
  29.  
  30. // centerspeed in work
  31. Recovery()
  32. {
  33.     recoverySpeed = CenterSpeed * FireTime/5;
  34.  
  35.     // |a| is absolute value from a: |-20|=20 and |20|=20
  36.     if (|sightX| < recoverySpeed)
  37.         sightX = 0;
  38.     else if (sight.X < 0)
  39.         sightX += recoverySpeed;
  40.     else if (sight.X > 0)
  41.         sightX -= recoverySpeed;
  42.  
  43.     if (|sight.Y| < recoverySpeed)
  44.         sightY = 0;
  45.     else if (sight.Y < 0)
  46.         sightY += recoverySpeed;
  47.     else if (sight.Y > 0)
  48.         sightY -= recoverySpeed;
  49. }
  50.  
  51. // this func returns sight to centre
  52. Centre()
  53. {
  54.     sightX = 0;
  55.     sightY = 0;
  56. }
  57.  
  58. // manual movement
  59. AddCompensation()
  60. {
  61.     sightX = sightX + compensationX;
  62.     sightY = sightY + compensationY;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement