Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shoot(burstsCount, roundsCount)
- {
- for (i = 0; i < burstsCount; i++) // do it burstsCount times
- {
- DrawBullet(sightX, sightY);
- for (k = 0; k < roundsCount; k++) // do it roundsCount times
- {
- ShootBullet();
- }
- Centre(); // set to centre after each burst
- }
- }
- ShootBullet()
- {
- Kick();
- Recovery();
- AddCompensation();
- }
- // this function kicks sight to random point
- Kick()
- {
- // random(a, b) returns random number between a and b
- // random(-10, 20) can return -7, 5, 7, 19, -2 etc
- sightX = sightX + random(Xmin, Xmax);
- sightY = sightY + random(Ymin, Ymax);
- }
- // centerspeed in work
- Recovery()
- {
- recoverySpeed = CenterSpeed * FireTime/5;
- // |a| is absolute value from a: |-20|=20 and |20|=20
- if (|sightX| < recoverySpeed)
- sightX = 0;
- else if (sight.X < 0)
- sightX += recoverySpeed;
- else if (sight.X > 0)
- sightX -= recoverySpeed;
- if (|sight.Y| < recoverySpeed)
- sightY = 0;
- else if (sight.Y < 0)
- sightY += recoverySpeed;
- else if (sight.Y > 0)
- sightY -= recoverySpeed;
- }
- // this func returns sight to centre
- Centre()
- {
- sightX = 0;
- sightY = 0;
- }
- // manual movement
- AddCompensation()
- {
- sightX = sightX + compensationX;
- sightY = sightY + compensationY;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement