Add project files.
This commit is contained in:
31
AlientAttack.MonoGame/GameLoops/GameLoopBase.cs
Normal file
31
AlientAttack.MonoGame/GameLoops/GameLoopBase.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
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()
|
||||
{
|
||||
SpriteBatch.Begin(transformMatrix: ViewTransform.ViewMatrix);
|
||||
|
||||
OnDraw();
|
||||
|
||||
SpriteBatch.End();
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
OnUpdate(gameTime);
|
||||
}
|
||||
|
||||
public abstract void OnDraw();
|
||||
public abstract void OnUpdate(GameTime gameTime);
|
||||
}
|
||||
Reference in New Issue
Block a user