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

@@ -27,8 +27,7 @@ public class Enemy02Green : EnemyShip
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Enemy02Green_Frame_{frame}_png_processed");
//SpriteEffects spriteEffects = SpriteEffects.None;
//args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, spriteEffects, 1);
base.Draw(args);
}

View File

@@ -27,8 +27,7 @@ public class Enemy02Red : EnemyShip
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Enemy02Red_Frame_{frame}_png_processed");
//SpriteEffects spriteEffects = SpriteEffects.None;
//args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, spriteEffects, 1);
base.Draw(args);
}

View File

@@ -27,8 +27,7 @@ public class Enemy02Teal : EnemyShip
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Enemy02_Teal_Frame_{frame}_png_processed");
//SpriteEffects spriteEffects = SpriteEffects.None;
//args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, spriteEffects, 1);
base.Draw(args);
}

View File

@@ -29,8 +29,7 @@ public class GreenEnemy : EnemyShip
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Enemy01_Green_Frame_1_png_processed");
SpriteEffects spriteEffects = SpriteEffects.None;
//args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, spriteEffects, 1);
base.Draw(args);
}

View File

@@ -9,8 +9,6 @@ public abstract class Mine : MoveableSprite
public const int Width = 65;
public const int Height = 64;
protected float Rotation = 0;
protected abstract string CoverColor { get; }
public Mine(int x, int y) : base(x, y)
@@ -25,7 +23,6 @@ public abstract class Mine : MoveableSprite
{
DrawRotor(args);
DrawCover(args);
//DrawCollisionBox(args);
}
private void DrawRotor(SpriteDrawArgs args)
@@ -40,35 +37,6 @@ public abstract class Mine : MoveableSprite
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, Origin, 1f, SpriteEffects.None, 1);
}
private void DrawCollisionBox(SpriteDrawArgs args)
{
//var pixel = DebugPixel; // static cached
Texture2D pixel = new Texture2D(args.SpriteBatch.GraphicsDevice, 1, 1);
pixel.SetData(new[] { Color.White });
//Rectangle r = GetWorldCollisionBox();
Color c = Color.LimeGreen; // debug color
// Top
args.SpriteBatch.Draw(pixel, new Rectangle(CollisionBox.X, CollisionBox.Y, CollisionBox.Width, 1), c);
// Bottom
args.SpriteBatch.Draw(pixel, new Rectangle(CollisionBox.X, CollisionBox.Bottom - 1, CollisionBox.Width, 1), c);
// Left
args.SpriteBatch.Draw(pixel, new Rectangle(CollisionBox.X, CollisionBox.Y, 1, CollisionBox.Height), c);
// Right
args.SpriteBatch.Draw(pixel, new Rectangle(CollisionBox.Right - 1, CollisionBox.Y, 1, CollisionBox.Height), c);
}
//Rectangle GetWorldCollisionBox()
//{
// int x = (int)(XPosition - Origin.X + BoundBox.X);
// int y = (int)(YPosition - Origin.Y + BoundBox.Y);
// return new Rectangle(x, y, BoundBox.Width, BoundBox.Height);
//}
public override sealed void Update(SpriteUpdateContext context)
{
base.Update(context);

View File

@@ -23,8 +23,7 @@ public class RedEnemy : EnemyShip
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Enemy01_Red_Frame_{frame}_png_processed");
//SpriteEffects spriteEffects = SpriteEffects.None;
//args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, spriteEffects, 1);
base.Draw(args);
}

View File

@@ -24,8 +24,7 @@ public class TealEnemy : EnemyShip
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Enemy01_Teal_Frame_{frame}_png_processed");
//SpriteEffects spriteEffects = SpriteEffects.None;
//args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, 1, spriteEffects, 1);
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, spriteEffects, 1);
base.Draw(args);
}

View File

@@ -14,8 +14,6 @@ public abstract class Turret : MoveableSprite
public const int GunWidth = 8;
public const int GunHeight = 38;
protected float Rotation = 0;
protected Vector2 MountOrigin = new(MountWidth / 2, MountHeight /2);
protected Vector2 TurretOrigin = new(TurretWidth / 2, TurretHeight / 2);
protected Vector2 GunOrigin = new(GunWidth / 2, GunHeight / 2);
@@ -34,7 +32,6 @@ public abstract class Turret : MoveableSprite
DrawMount(args);
DrawTurret(args);
DrawGun(args);
//DrawCollisionBox(args);
}
private void DrawMount(SpriteDrawArgs args)
@@ -55,27 +52,6 @@ public abstract class Turret : MoveableSprite
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, GunOrigin, 1f, SpriteEffects.None, 1);
}
private void DrawCollisionBox(SpriteDrawArgs args)
{
//var pixel = DebugPixel; // static cached
Texture2D pixel = new Texture2D(args.SpriteBatch.GraphicsDevice, 1, 1);
pixel.SetData(new[] { Color.White });
//Rectangle r = GetWorldCollisionBox();
Color c = Color.LimeGreen; // debug color
// Top
args.SpriteBatch.Draw(pixel, new Rectangle(CollisionBox.X, CollisionBox.Y, CollisionBox.Width, 1), c);
// Bottom
args.SpriteBatch.Draw(pixel, new Rectangle(CollisionBox.X, CollisionBox.Bottom - 1, CollisionBox.Width, 1), c);
// Left
args.SpriteBatch.Draw(pixel, new Rectangle(CollisionBox.X, CollisionBox.Y, 1, CollisionBox.Height), c);
// Right
args.SpriteBatch.Draw(pixel, new Rectangle(CollisionBox.Right - 1, CollisionBox.Y, 1, CollisionBox.Height), c);
}
public override sealed void Update(SpriteUpdateContext context)
{
base.Update(context);