Advertisement
leafbarrett

muzzle code

Jan 22nd, 2017
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
  2. {
  3. int numberProjectiles = 10;
  4. for (int i = 0; i < numberProjectiles; i++)
  5. {
  6. Vector2 muzzleOffset = Vector2.Normalize(new Vector2(speedX, speedY));
  7. if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0))
  8. {
  9. position += muzzleOffset;
  10. //should set the shots to originate at the muzzle? is there a variable the example doesn't give that I should have here?
  11. }
  12. Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedByRandom(MathHelper.ToRadians(35)); // 30 degree spread.
  13. Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
  14. }
  15. return true;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement