Add project files.
This commit is contained in:
38
AlientAttack.MonoGame/Things/Sprite.cs
Normal file
38
AlientAttack.MonoGame/Things/Sprite.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things;
|
||||
|
||||
public class Sprite(float x, float y)
|
||||
{
|
||||
public float XPosition { get; protected set; } = x;
|
||||
public float YPosition { get; protected set; } = y;
|
||||
public Vector2 Position => new(XPosition, YPosition);
|
||||
public Rectangle BoundBox { get; protected set; }
|
||||
|
||||
protected Rectangle CollisionBox;
|
||||
protected Color DrawColor = Color.White;
|
||||
|
||||
public bool CanCollide { get; protected set; } = true;
|
||||
public bool IsDead { get; protected set; }
|
||||
|
||||
public virtual void Update(SpriteUpdateContext context)
|
||||
{
|
||||
CollisionBox = new Rectangle((int)XPosition + BoundBox.X, (int)YPosition + BoundBox.Y, BoundBox.Width, BoundBox.Height);
|
||||
}
|
||||
|
||||
public bool Intersects(Sprite sprite)
|
||||
{
|
||||
return CollisionBox.Intersects(sprite.CollisionBox);
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteDrawArgs args)
|
||||
{
|
||||
//spriteBatch.Draw(Texture, Position, DrawColor);
|
||||
}
|
||||
|
||||
public virtual void OnCollision(SpriteCollisionContext context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user