Files
alien-attack/AlientAttack.MonoGame/Things/Muzzles/MuzzleMath.cs

20 lines
577 B
C#

using Microsoft.Xna.Framework;
namespace AlienAttack.MonoGame.Things.Muzzles;
public static class MuzzleMath
{
public static Vector2 GetMuzzleWorld(Sprite owner, Vector2 muzzleLocalPx, float ownerScale = 1f)
{
// Assumes owner.Position is the top-left of the sprite
return owner.Position + muzzleLocalPx * ownerScale;
}
public static Vector2 CenterBulletOn(Vector2 muzzleWorld, int bulletW, int bulletH)
{
return new Vector2(
muzzleWorld.X - bulletW / 2f,
muzzleWorld.Y - bulletH / 2f
);
}
}