Added more sound effects. Added initial weapon muzzle fire logic.
This commit is contained in:
9
AlientAttack.MonoGame/Things/Muzzles/Muzzle.cs
Normal file
9
AlientAttack.MonoGame/Things/Muzzles/Muzzle.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Muzzles;
|
||||
|
||||
public readonly struct Muzzle(MuzzleId id, Vector2 localPx)
|
||||
{
|
||||
public MuzzleId Id { get; } = id;
|
||||
public Vector2 LocalPx { get; } = localPx;
|
||||
}
|
||||
8
AlientAttack.MonoGame/Things/Muzzles/MuzzleId.cs
Normal file
8
AlientAttack.MonoGame/Things/Muzzles/MuzzleId.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace AlienAttack.MonoGame.Things.Muzzles;
|
||||
|
||||
public enum MuzzleId
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
20
AlientAttack.MonoGame/Things/Muzzles/MuzzleMath.cs
Normal file
20
AlientAttack.MonoGame/Things/Muzzles/MuzzleMath.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user