Files
alien-attack/AlientAttack.MonoGame/GameLoops/GameLoopBase.cs

31 lines
886 B
C#

using AlienAttack.MonoGame.View;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace AlienAttack.MonoGame.GameLoops;
internal abstract class GameLoopBase(AlienAttackGame game) : IGameLoop
{
protected readonly AlienAttackGame Game = game;
protected readonly ContentManager Content = game.Content;
protected readonly SpriteBatch SpriteBatch = game.SpriteBatch;
protected readonly ViewTransform ViewTransform = game.ViewTransform;
public void Draw(GameTime gameTime)
{
SpriteBatch.Begin(transformMatrix: ViewTransform.ViewMatrix);
OnDraw(gameTime);
SpriteBatch.End();
}
public void Update(GameTime gameTime)
{
OnUpdate(gameTime);
}
public abstract void OnDraw(GameTime gameTime);
public abstract void OnUpdate(GameTime gameTime);
}