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

34 lines
1016 B
C#

using AlienAttack.MonoGame.Audio;
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;
protected readonly AudioManager Audio = game.Audio;
public void Draw(GameTime gameTime)
{
SpriteBatch.Begin(transformMatrix: ViewTransform.ViewMatrix);
OnDraw(gameTime);
SpriteBatch.End();
}
public void Update(GameTime gameTime)
{
Audio.UpdateWithDuck(gameTime);
OnUpdate(gameTime);
}
public abstract void OnDraw(GameTime gameTime);
public abstract void OnUpdate(GameTime gameTime);
}