Updated asteriods, mines, and explosions.
This commit is contained in:
@@ -1,27 +1,28 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using AlienAttack.MonoGame.Things.Explosions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Asteroids;
|
||||
|
||||
public class Asteroid : MoveableSprite
|
||||
public abstract class Asteroid : MoveableSprite
|
||||
{
|
||||
public const int Width = 39;
|
||||
public const int Height = 37;
|
||||
protected abstract int MaxHealth { get; }
|
||||
protected abstract string TextureName { get; }
|
||||
|
||||
protected float Rotation = 0;
|
||||
protected int Health { get; set; }
|
||||
protected float RotationSpeed { get; set; } = 1f;
|
||||
|
||||
public Asteroid(int x, int y) : base(x, y)
|
||||
{
|
||||
Origin = new(Width / 2, Height / 2);
|
||||
BoundBox = new(0, 0, Width, Height);
|
||||
YVelocity = 1;
|
||||
XVelocity = 0;
|
||||
Health = MaxHealth;
|
||||
RotationSpeed = 1f;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>("Sprites/Asteroid 01");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, Origin, 1f, SpriteEffects.None, 1);
|
||||
Texture2D texture = args.Textures.Get(TextureName);
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, Origin, Scale, SpriteEffects.None, 1);
|
||||
|
||||
base.Draw(args);
|
||||
}
|
||||
@@ -32,17 +33,33 @@ public class Asteroid : MoveableSprite
|
||||
|
||||
CollisionBox = new Rectangle((int)XPosition + BoundBox.X - (int)Origin.X, (int)YPosition + BoundBox.Y - (int)Origin.Y, BoundBox.Width, BoundBox.Height);
|
||||
|
||||
if (Health <= 0)
|
||||
{
|
||||
IsDead = true;
|
||||
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
context.AudioManager.PlayExplosion();
|
||||
return;
|
||||
}
|
||||
|
||||
if (YPosition - Origin.Y > context.ViewTransform.ScreenHeight)
|
||||
{
|
||||
IsDead = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Rotation += 0.01f;
|
||||
Rotation = MathHelper.WrapAngle(Rotation + RotationSpeed * context.DeltaTime);
|
||||
}
|
||||
|
||||
if (Rotation > 360f)
|
||||
public override void OnCollision(SpriteCollisionContext context)
|
||||
{
|
||||
if (context.Sprite is Bullet bullet && bullet.Owner is Player)
|
||||
{
|
||||
Rotation = 0;
|
||||
Health -= bullet.Damage;
|
||||
}
|
||||
|
||||
if (context.Sprite is Player)
|
||||
{
|
||||
Health = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
AlientAttack.MonoGame/Things/Asteroids/AsteroidVariantA.cs
Normal file
20
AlientAttack.MonoGame/Things/Asteroids/AsteroidVariantA.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AlienAttack.MonoGame.Textures;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Asteroids;
|
||||
|
||||
public class AsteroidVariantA : Asteroid
|
||||
{
|
||||
public const int Width = 39;
|
||||
public const int Height = 37;
|
||||
|
||||
protected override string TextureName => TextureNames.Asteriods.VariantA;
|
||||
protected override int MaxHealth => 8;
|
||||
|
||||
public AsteroidVariantA(int x, int y) : base(x, y)
|
||||
{
|
||||
Origin = new(Width / 2, Height / 2);
|
||||
BoundBox = new(0, 0, Width, Height);
|
||||
YVelocity = 1;
|
||||
XVelocity = 0;
|
||||
}
|
||||
}
|
||||
20
AlientAttack.MonoGame/Things/Asteroids/AsteroidVariantB.cs
Normal file
20
AlientAttack.MonoGame/Things/Asteroids/AsteroidVariantB.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AlienAttack.MonoGame.Textures;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Asteroids;
|
||||
|
||||
public class AsteroidVariantB : Asteroid
|
||||
{
|
||||
public const int Width = 26;
|
||||
public const int Height = 28;
|
||||
|
||||
protected override string TextureName => TextureNames.Asteriods.VariantB;
|
||||
protected override int MaxHealth => 4;
|
||||
|
||||
public AsteroidVariantB(int x, int y) : base(x, y)
|
||||
{
|
||||
Origin = new(Width / 2, Height / 2);
|
||||
BoundBox = new(0, 0, Width, Height);
|
||||
YVelocity = 2;
|
||||
XVelocity = 0;
|
||||
}
|
||||
}
|
||||
20
AlientAttack.MonoGame/Things/Asteroids/AsteroidVariantC.cs
Normal file
20
AlientAttack.MonoGame/Things/Asteroids/AsteroidVariantC.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AlienAttack.MonoGame.Textures;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Asteroids;
|
||||
|
||||
public class AsteroidVariantC : Asteroid
|
||||
{
|
||||
public const int Width = 37;
|
||||
public const int Height = 36;
|
||||
|
||||
protected override string TextureName => TextureNames.Asteriods.VariantC;
|
||||
protected override int MaxHealth => 5;
|
||||
|
||||
public AsteroidVariantC(int x, int y) : base(x, y)
|
||||
{
|
||||
Origin = new(Width / 2, Height / 2);
|
||||
BoundBox = new(0, 0, Width, Height);
|
||||
YVelocity = 1.5f;
|
||||
XVelocity = 0;
|
||||
}
|
||||
}
|
||||
20
AlientAttack.MonoGame/Things/Asteroids/AsteroidVariantD.cs
Normal file
20
AlientAttack.MonoGame/Things/Asteroids/AsteroidVariantD.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AlienAttack.MonoGame.Textures;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Asteroids;
|
||||
|
||||
public class AsteroidVariantD : Asteroid
|
||||
{
|
||||
public const int Width = 44;
|
||||
public const int Height = 35;
|
||||
|
||||
protected override string TextureName => TextureNames.Asteriods.VariantD;
|
||||
protected override int MaxHealth => 10;
|
||||
|
||||
public AsteroidVariantD(int x, int y) : base(x, y)
|
||||
{
|
||||
Origin = new(Width / 2, Height / 2);
|
||||
BoundBox = new(0, 0, Width, Height);
|
||||
YVelocity = .5f;
|
||||
XVelocity = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using AlienAttack.MonoGame.Textures;
|
||||
using AlienAttack.MonoGame.Things.Explosions;
|
||||
using AlienAttack.MonoGame.Things.Items;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using AlienAttack.MonoGame.Things.Explosions;
|
||||
using AlienAttack.MonoGame.Things.Items;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using AlienAttack.MonoGame.Things.Explosions;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies;
|
||||
|
||||
@@ -3,4 +3,6 @@
|
||||
public class BlueMine(int x, int y) : Mine(x, y)
|
||||
{
|
||||
protected override string CoverColor => "Blue";
|
||||
protected override float ExplodeRadius => 100f;
|
||||
protected override int MaxHealth => 10;
|
||||
}
|
||||
@@ -3,4 +3,6 @@
|
||||
public class GreenMine(int x, int y) : Mine(x, y)
|
||||
{
|
||||
protected override string CoverColor => "Green";
|
||||
protected override float ExplodeRadius => 100f;
|
||||
protected override int MaxHealth => 10;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using AlienAttack.MonoGame.Things.Explosions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
@@ -9,7 +11,13 @@ public abstract class Mine : MoveableSprite
|
||||
public const int Width = 65;
|
||||
public const int Height = 64;
|
||||
|
||||
protected abstract int MaxHealth { get; }
|
||||
protected abstract string CoverColor { get; }
|
||||
protected abstract float ExplodeRadius { get; }
|
||||
|
||||
protected int Health { get; set; }
|
||||
protected float RotationSpeed { get; set; } = 1.5f;
|
||||
protected double DistanceToPlayer { get; set; } = double.MaxValue;
|
||||
|
||||
public Mine(int x, int y) : base(x, y)
|
||||
{
|
||||
@@ -17,38 +25,45 @@ public abstract class Mine : MoveableSprite
|
||||
BoundBox = new(10, 14, 40, 38);
|
||||
YVelocity = 1;
|
||||
XVelocity = 0;
|
||||
Health = MaxHealth;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteDrawArgs args)
|
||||
{
|
||||
DrawRotor(args);
|
||||
DrawCover(args);
|
||||
|
||||
base.Draw(args);
|
||||
}
|
||||
|
||||
private void DrawRotor(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>("Sprites/Rotor");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, Origin, 1f, SpriteEffects.None, 1);
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, Origin, Scale, SpriteEffects.None, 1);
|
||||
}
|
||||
|
||||
private void DrawCover(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>($"Sprites/Cover_{CoverColor}");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, Origin, 1f, SpriteEffects.None, 1);
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, Origin, Scale, SpriteEffects.None, 1);
|
||||
}
|
||||
|
||||
public override sealed void Update(SpriteUpdateContext context)
|
||||
{
|
||||
base.Update(context);
|
||||
|
||||
CollisionBox = new Rectangle((int)XPosition + BoundBox.X - (int)Origin.X, (int)YPosition + BoundBox.Y - (int)Origin.Y, BoundBox.Width, BoundBox.Height);
|
||||
if (Health <= 0)
|
||||
{
|
||||
IsDead = true;
|
||||
SpawnExplosion(context);
|
||||
//OnKilled(context);
|
||||
return;
|
||||
}
|
||||
|
||||
float xDiff = (XPosition + Origin.X) - (context.Player.XPosition + context.Player.Origin.X);
|
||||
float yDiff = (YPosition + Origin.Y) - (context.Player.YPosition + context.Player.Origin.Y);
|
||||
UpdateDistanceToPlayer(context);
|
||||
OnUpdate(context);
|
||||
|
||||
double distance = Math.Sqrt(xDiff * xDiff + yDiff * yDiff);
|
||||
|
||||
if (distance < 100)
|
||||
if (DistanceToPlayer <= ExplodeRadius)
|
||||
{
|
||||
IsDead = true;
|
||||
SpawnExplosion(context);
|
||||
@@ -61,17 +76,38 @@ public abstract class Mine : MoveableSprite
|
||||
return;
|
||||
}
|
||||
|
||||
Rotation += 0.01f;
|
||||
Rotation = MathHelper.WrapAngle(Rotation + RotationSpeed * context.DeltaTime);
|
||||
}
|
||||
|
||||
if (Rotation > 360f)
|
||||
private void UpdateDistanceToPlayer(SpriteUpdateContext context)
|
||||
{
|
||||
float xDiff = (XPosition + Origin.X) - (context.Player.XPosition + context.Player.Origin.X);
|
||||
float yDiff = (YPosition + Origin.Y) - (context.Player.YPosition + context.Player.Origin.Y);
|
||||
|
||||
DistanceToPlayer = Math.Sqrt(xDiff * xDiff + yDiff * yDiff);
|
||||
}
|
||||
|
||||
protected virtual void OnUpdate(SpriteUpdateContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnCollision(SpriteCollisionContext context)
|
||||
{
|
||||
if (context.Sprite is Bullet bullet && bullet.Owner is Player)
|
||||
{
|
||||
Rotation = 0;
|
||||
Health -= bullet.Damage;
|
||||
}
|
||||
|
||||
if (context.Sprite is Player)
|
||||
{
|
||||
Health = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnExplosion(SpriteUpdateContext context)
|
||||
protected void SpawnExplosion(SpriteUpdateContext context)
|
||||
{
|
||||
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
context.SpawnSprite(new MineExplosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
context.AudioManager.PlayExplosion();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,78 @@
|
||||
namespace AlienAttack.MonoGame.Things.Enemies.Mines;
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies.Mines;
|
||||
|
||||
public class RedMine(int x, int y) : Mine(x, y)
|
||||
{
|
||||
protected bool IsCharging = false;
|
||||
protected Vector2 TargetCenter;
|
||||
protected override string CoverColor => "Red";
|
||||
protected override float ExplodeRadius => 18f;
|
||||
protected override int MaxHealth => 10;
|
||||
|
||||
// Tunables
|
||||
private const float DetectRange = 200f;
|
||||
private const float ChargeSpeed = 5f; // try 3.5–6.0
|
||||
|
||||
protected override void OnUpdate(SpriteUpdateContext context)
|
||||
{
|
||||
// If not charging yet, see if we should lock on
|
||||
if (!IsCharging)
|
||||
{
|
||||
if (DistanceToPlayer > DetectRange)
|
||||
return;
|
||||
|
||||
Charge(context.Player);
|
||||
}
|
||||
|
||||
// We are charging: steer directly toward the locked target point
|
||||
Vector2 toTarget = TargetCenter - new Vector2(XPosition + Origin.X, YPosition + Origin.Y);
|
||||
|
||||
float dist = toTarget.Length();
|
||||
|
||||
if (dist <= ExplodeRadius)
|
||||
{
|
||||
IsDead = true;
|
||||
|
||||
// Optionally: explode at target (top-left adjustment)
|
||||
XPosition = TargetCenter.X - Origin.X;
|
||||
YPosition = TargetCenter.Y - Origin.Y;
|
||||
|
||||
SpawnExplosion(context); // uses current XPosition/YPosition
|
||||
return;
|
||||
}
|
||||
|
||||
// Normalize direction (avoid NaN if dist == 0)
|
||||
Vector2 dir = toTarget / dist;
|
||||
|
||||
// Set velocities for base.Update to apply next frame
|
||||
XVelocity = dir.X * ChargeSpeed;
|
||||
YVelocity = dir.Y * ChargeSpeed;
|
||||
|
||||
// Optional: if you want it to stop “floating down” once charging
|
||||
// (it will anyway, because we overwrite YVelocity)
|
||||
}
|
||||
|
||||
public override void OnCollision(SpriteCollisionContext context)
|
||||
{
|
||||
base.OnCollision(context);
|
||||
|
||||
if (context.Sprite is Bullet bullet && bullet.Owner is Player player && IsCharging == false)
|
||||
{
|
||||
Charge(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void Charge(Sprite target)
|
||||
{
|
||||
IsCharging = true;
|
||||
|
||||
float x = target.XPosition + target.Origin.X;
|
||||
float y = target.YPosition + target.Origin.Y;
|
||||
|
||||
TargetCenter = new Vector2(x, y);
|
||||
|
||||
RotationSpeed *= ChargeSpeed;
|
||||
}
|
||||
}
|
||||
@@ -37,19 +37,19 @@ public abstract class Turret : MoveableSprite
|
||||
private void DrawMount(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>("Sprites/GunTurretMount");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, MountOrigin, 1f, SpriteEffects.None, 1);
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, MountOrigin, Scale, SpriteEffects.None, 1);
|
||||
}
|
||||
|
||||
private void DrawTurret(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>($"Sprites/GunTurret_{TurretColor}");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, TurretOrigin, 1f, SpriteEffects.None, 1);
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, TurretOrigin, Scale, SpriteEffects.None, 1);
|
||||
}
|
||||
|
||||
private void DrawGun(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>("Sprites/GunTurret_ExampleGun");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, GunOrigin, 1f, SpriteEffects.None, 1);
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, Rotation, GunOrigin, Scale, SpriteEffects.None, 1);
|
||||
}
|
||||
|
||||
public override sealed void Update(SpriteUpdateContext context)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things;
|
||||
namespace AlienAttack.MonoGame.Things.Explosions;
|
||||
|
||||
public class Explosion : MoveableSprite
|
||||
{
|
||||
protected int CurrentFrame { get; private set; } = 1;
|
||||
protected int MaxFrames => 9;
|
||||
protected int AnimationThreshold => 3; //5;
|
||||
protected int AnimationThreshold => 3;
|
||||
protected int CurrentThreshold { get; private set; } = 5;
|
||||
|
||||
public Explosion(int x, int y, float xVel, float yVel) : base(x, y)
|
||||
@@ -19,9 +18,8 @@ public class Explosion : MoveableSprite
|
||||
|
||||
public override void Draw(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Explosion01_Frame_0{CurrentFrame}_png_processed");
|
||||
//args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1f, SpriteEffects.None, 1);
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, 1f, SpriteEffects.None, 1);
|
||||
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Explosion01_Frame_0{CurrentFrame}");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, SpriteEffects.None, 1);
|
||||
|
||||
base.Draw(args);
|
||||
}
|
||||
@@ -30,9 +28,6 @@ public class Explosion : MoveableSprite
|
||||
{
|
||||
base.Update(context);
|
||||
|
||||
//XPosition += XVelocity;
|
||||
//YPosition += YVelocity;
|
||||
|
||||
if (CurrentThreshold > 0)
|
||||
{
|
||||
CurrentThreshold--;
|
||||
11
AlientAttack.MonoGame/Things/Explosions/MineExplosion.cs
Normal file
11
AlientAttack.MonoGame/Things/Explosions/MineExplosion.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Explosions;
|
||||
|
||||
public class MineExplosion : Explosion
|
||||
{
|
||||
public MineExplosion(int x, int y, float xVel, float yVel) : base(x, y, xVel, yVel)
|
||||
{
|
||||
Scale = new(2, 2);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things;
|
||||
namespace AlienAttack.MonoGame.Things.Explosions;
|
||||
|
||||
public class MiniExplosion : MoveableSprite
|
||||
{
|
||||
protected int CurrentFrame { get; private set; } = 1;
|
||||
protected int MaxFrames => 9;
|
||||
protected int AnimationThreshold => 3; //5;
|
||||
protected int AnimationThreshold => 3;
|
||||
protected int CurrentThreshold { get; private set; } = 5;
|
||||
|
||||
public MiniExplosion(int x, int y, float xVel, float yVel) : base(x, y)
|
||||
@@ -14,12 +14,13 @@ public class MiniExplosion : MoveableSprite
|
||||
Origin = new(32.5f, 32);
|
||||
XVelocity = xVel;
|
||||
YVelocity = yVel;
|
||||
Scale = new(.25f, .25f);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Explosion01_Frame_0{CurrentFrame}_png_processed");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, .25f, SpriteEffects.None, 1);
|
||||
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Explosion01_Frame_0{CurrentFrame}");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, SpriteEffects.None, 1);
|
||||
|
||||
base.Draw(args);
|
||||
}
|
||||
@@ -28,9 +29,6 @@ public class MiniExplosion : MoveableSprite
|
||||
{
|
||||
base.Update(context);
|
||||
|
||||
//XPosition += xVel;
|
||||
//YPosition += yVel;
|
||||
|
||||
if (CurrentThreshold > 0)
|
||||
{
|
||||
CurrentThreshold--;
|
||||
@@ -151,7 +151,7 @@ public class Player : MoveableSprite
|
||||
|
||||
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\PlayerRed_Frame_{frameNumber}");
|
||||
//args.SpriteBatch.Draw(texture, Position, DrawColor);
|
||||
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);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class Player : MoveableSprite
|
||||
private void DrawExhaust(SpriteDrawArgs args)
|
||||
{
|
||||
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Exhaust_Frame_0{CurrentExhaustFrame}_png_processed");
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1, SpriteEffects.None, 1);
|
||||
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, Origin, Scale, SpriteEffects.None, 1);
|
||||
}
|
||||
|
||||
private string GetPlayerTextureName()
|
||||
|
||||
@@ -12,6 +12,7 @@ public class SpriteUpdateContext(AlienAttackGame game)
|
||||
public required Action<Sprite> SpawnSprite { get; init; }
|
||||
public required Random Random { get; init; }
|
||||
public required GameTime GameTime { get; init; }
|
||||
public float DeltaTime => (float)GameTime.ElapsedGameTime.TotalSeconds;
|
||||
public required ContentManager Content { get; init; }
|
||||
public AudioManager AudioManager => game.Audio;
|
||||
public required Player Player { get; init; }
|
||||
|
||||
Reference in New Issue
Block a user