Added texture cache and sprite origins.
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies;
|
||||
|
||||
public abstract class EnemyShip(int x, int y) : MoveableSprite(x, y)
|
||||
public abstract class EnemyShip : MoveableSprite
|
||||
{
|
||||
protected abstract int Health { get; set; }
|
||||
|
||||
public virtual int CrashDamage => 10;
|
||||
|
||||
public EnemyShip(int x, int y) : base(x, y)
|
||||
{
|
||||
Origin = new(32, 32);
|
||||
}
|
||||
|
||||
public override sealed void Update(SpriteUpdateContext context)
|
||||
{
|
||||
if (Health <= 0)
|
||||
@@ -22,7 +28,7 @@ public abstract class EnemyShip(int x, int y) : MoveableSprite(x, y)
|
||||
|
||||
TryMove(context);
|
||||
|
||||
if (YPosition > context.ViewTransform.ScreenHeight)
|
||||
if (YPosition - Origin.Y > context.ViewTransform.ScreenHeight)
|
||||
{
|
||||
IsDead = true;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user