Added sprite rotation and scale. Refactored bullet classes.

This commit is contained in:
2026-01-15 00:20:09 -05:00
parent 61d51f5188
commit 8e0a68efdf
25 changed files with 60 additions and 226 deletions

View File

@@ -1,7 +1,4 @@
using AlienAttack.MonoGame.Textures;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
namespace AlienAttack.MonoGame.Things.Bullets;
@@ -10,19 +7,12 @@ public class LaserBulletSmall : Bullet
public const int Width = 6;
public const int Height = 18;
protected override string TextureName => TextureNames.Bullets.LaserSmall;
public LaserBulletSmall(float x, float y, float xVel, float yVel, Sprite owner) : base(x, y, xVel, yVel, owner)
{
Origin = new(Width / 2, Height / 2);
BoundBox = new(0, 0, Width, Height);
Damage = 1;
}
public override void Draw(SpriteDrawArgs args)
{
Texture2D texture = args.Textures.Get(TextureNames.Bullets.LaserSmall);
float rotation = MathF.Atan2(YVelocity, XVelocity) + MathF.PI / 2f;
args.SpriteBatch.Draw(texture, Position, null, DrawColor, rotation, Origin, 1f, SpriteEffects.None, 1);
}
}