fix some errata
continuous-integration/drone/push Build is passing Details

main
Evan Hemsley 2020-07-21 13:28:14 -07:00
parent 0681448f1e
commit 67a241a7d1
3 changed files with 27 additions and 11 deletions

View File

@ -18,7 +18,7 @@ namespace PongFE.Renderers
{
public class Texture2DRenderer : OrderedRenderer<Texture2DComponent>
{
public override void Render(Entity entity, in Texture2DComponent drawComponent)
public override void Render(Entity entity, in Texture2DComponent textureComponent)
{
}
@ -46,6 +46,7 @@ Now let's fill out the Renderer some more.
```cs
using Encompass;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using PongFE.Components;
@ -118,6 +119,10 @@ When we define a method in this way, it means that we can add a new method to an
Now we can rewrite our SpriteBatch draw call:
```cs
using PongFE.Extensions;
...
_spriteBatch.Draw(
textureComponent.Texture,
positionComponent.Position.ToXNAVector(),

View File

@ -17,6 +17,8 @@ using Encompass;
using Microsoft.Xna.Framework.Input;
using PongFE.Messages;
namespace PongFE.Engines
{
public class InputEngine : Engine
{
public override void Update(double dt)
@ -29,6 +31,7 @@ public class InputEngine : Engine
}
}
}
}
```
*record scratch*

View File

@ -11,6 +11,8 @@ Create a file: **PongFE/Engines/MotionEngine.cs**
```cs
using Encompass;
namespace PongFE.Engines
{
public class MotionEngine : Engine
{
public override void Update(double dt)
@ -18,6 +20,7 @@ public class MotionEngine : Engine
}
}
}
```
Every Engine must implement an *Update* method, which takes a *delta-time* value as a parameter.
@ -78,6 +81,12 @@ namespace PongFE.Engines
}
```
Let's add this engine to the WorldBuilder.
```cs
WorldBuilder.AddEngine(new MotionEngine());
```
If we run the game right now, Encompass will yell at us. Why? Because it can't guarantee that this Engine runs after Engines which *send* MotionMessages, which is no good. So we need to declare what is called a *class attribute* on the Engine. We'll talk about sending messages soon. But for now, we need to let Encompass know that this Engine will be receiving MotionMessages with a *Receives* attribute.
```cs
@ -165,11 +174,10 @@ namespace PongFE.Engines
}
```
Before we move on any farther, let's make sure to add this Engine to our WorldBuilder.
Before we move on any farther, let's make sure to add this Renderer to our WorldBuilder.
```cs
...
WorldBuilder.AddEngine(new MotionEngine());
WorldBuilder.AddOrderedRenderer(new Texture2DRenderer(SpriteBatch));
...
```