some tutorial fixes
continuous-integration/drone/push Build is passing Details

main
cosmonaut 2021-05-01 16:03:20 -07:00
parent be028dd21c
commit 6c13f42a90
8 changed files with 22 additions and 26 deletions

View File

@ -32,7 +32,7 @@ namespace MyGame.Renderers
this.gridSize = 16; this.gridSize = 16;
} }
public override void Render() public override void Render(double dt, double alpha)
{ {
if (SomeComponent<EditorModeComponent>() && SomeComponent<MouseComponent>()) if (SomeComponent<EditorModeComponent>() && SomeComponent<MouseComponent>())
{ {

View File

@ -18,7 +18,7 @@ namespace PongFE.Renderers
{ {
public class Texture2DRenderer : Renderer public class Texture2DRenderer : Renderer
{ {
public override void Render() public override void Render(double dt, double alpha)
{ {
} }
@ -59,13 +59,14 @@ namespace PongFE.Renderers
_spriteBatch = spriteBatch; _spriteBatch = spriteBatch;
} }
public override void Render() public override void Render(double dt, double alpha)
{ {
SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
foreach (ref readonly var entity in ReadEntities<Texture2DComponent>()) foreach (ref readonly var entity in ReadEntities<Texture2DComponent>())
{ {
ref readonly var positionComponent = ref GetComponent<PositionComponent>(entity); ref readonly var positionComponent = ref GetComponent<PositionComponent>(entity);
ref readonly var textureComponent = ref GetComponent<Texture2DComponent>(entity);
_spriteBatch.Draw( _spriteBatch.Draw(
textureComponent.Texture, textureComponent.Texture,
@ -129,7 +130,6 @@ Now we can rewrite our SpriteBatch draw call:
using PongFE.Extensions; using PongFE.Extensions;
... ...
_spriteBatch.Draw( _spriteBatch.Draw(
textureComponent.Texture, textureComponent.Texture,
positionComponent.Position.ToXNAVector(), positionComponent.Position.ToXNAVector(),

View File

@ -98,9 +98,6 @@ Remove Width and Height from Texture2DComponent, and add a ScaleComponent in bot
Then, in **Texture2DRenderer.cs** we can do: Then, in **Texture2DRenderer.cs** we can do:
```cs ```cs
public override void Render(Entity entity, in Texture2DComponent textureComponent)
{
ref readonly var positionComponent = ref GetComponent<PositionComponent>(entity);
ref readonly var scaleComponent = ref GetComponent<ScaleComponent>(entity); ref readonly var scaleComponent = ref GetComponent<ScaleComponent>(entity);
_spriteBatch.Draw( _spriteBatch.Draw(
@ -114,7 +111,6 @@ Then, in **Texture2DRenderer.cs** we can do:
SpriteEffects.None, SpriteEffects.None,
0 0
); );
}
``` ```
Now, in **PongFE/Engines/AngledBounceEngine.cs**: Now, in **PongFE/Engines/AngledBounceEngine.cs**:

View File

@ -185,7 +185,7 @@ namespace PongFE.Renderers
InstructionFont = instructionFont; InstructionFont = instructionFont;
} }
public override void Render() public override void Render(double dt, double alpha)
{ {
ref readonly var gameStateComponent = ref ReadComponent<GameStateComponent>(); ref readonly var gameStateComponent = ref ReadComponent<GameStateComponent>();
ref readonly var playAreaComponent = ref ReadComponent<PlayAreaComponent>(); ref readonly var playAreaComponent = ref ReadComponent<PlayAreaComponent>();
@ -215,7 +215,7 @@ namespace PongFE.Renderers
And let's tweak the *CenterLineRenderer.Render* method a bit. And let's tweak the *CenterLineRenderer.Render* method a bit.
```cs ```cs
public override void Render() public override void Render(double dt, double alpha)
{ {
ref readonly var gameStateComponent = ref ReadComponent<GameStateComponent>(); ref readonly var gameStateComponent = ref ReadComponent<GameStateComponent>();

View File

@ -102,7 +102,7 @@ namespace PongFE.Renderers
SpriteBatch = spriteBatch; SpriteBatch = spriteBatch;
} }
public override void Render() public override void Render(double dt, double alpha)
{ {
SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Nonpremultiplied); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Nonpremultiplied);

View File

@ -30,7 +30,7 @@ namespace PongFE.Renderers
WhitePixel = whitePixel; WhitePixel = whitePixel;
} }
public override void Render() public override void Render(double dt, double alpha)
{ {
ref readonly var playAreaComponent = ref ReadComponent<PlayAreaComponent>(); ref readonly var playAreaComponent = ref ReadComponent<PlayAreaComponent>();

View File

@ -82,7 +82,7 @@ Go through the rest of **PongFEGame.cs** and replace the magic values 1280 and 7
Let's revise our **ScoreRenderer** too. Let's revise our **ScoreRenderer** too.
```cs ```cs
public override void Render() public override void Render(double dt, double alpha)
{ {
int? playerOneScore = null; int? playerOneScore = null;
int? playerTwoScore = null; int? playerTwoScore = null;

View File

@ -148,7 +148,7 @@ namespace PongFE.Renderers
Font = font; Font = font;
} }
public override void Render() public override void Render(double dt, double alpha)
{ {
int? playerOneScore = null; int? playerOneScore = null;
int? playerTwoScore = null; int? playerTwoScore = null;