Add project files.

This commit is contained in:
2025-12-16 08:51:34 -05:00
parent ed4d50a5bd
commit f7e3fe0a47
140 changed files with 2946 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using AlienAttack.MonoGame.Things.Items;
namespace AlienAttack.MonoGame.Things.Bullets;
internal class Bullet(float x, float y, float xVel, float yVel, Sprite owner) : Sprite(x, y)
{
protected float XVelocity = xVel;
protected float YVelocity = yVel;
public Sprite Owner { get; protected set; } = owner;
public int Damage { get; protected set; } = 0;
public override void Draw(SpriteDrawArgs args)
{
base.Draw(args);
}
public override void Update(SpriteUpdateContext context)
{
XPosition += XVelocity;
YPosition += YVelocity;
if (XPosition + BoundBox.Width < 0
|| XPosition > context.ViewTransform.ScreenWidth
|| YPosition + BoundBox.Height < 0
|| YPosition > context.ViewTransform.ScreenHeight)
{
IsDead = true;
}
base.Update(context);
}
public override void OnCollision(SpriteCollisionContext context)
{
if (context.Sprite is Bullet || context.Sprite == Owner || context.Sprite is Item)
return;
IsDead = true;
float xVel = 0;
float yVel = 0;
if (context.Sprite is MoveableSprite moveableSprite)
{
xVel = moveableSprite.XVelocity;
yVel = moveableSprite.YVelocity;
}
context.SpawnSprite(new MiniExplosion((int)XPosition, (int)YPosition, xVel, yVel));
}
}