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 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 ```cs
using Encompass; using Encompass;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using PongFE.Components; 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: Now we can rewrite our SpriteBatch draw call:
```cs ```cs
using PongFE.Extensions;
...
_spriteBatch.Draw( _spriteBatch.Draw(
textureComponent.Texture, textureComponent.Texture,
positionComponent.Position.ToXNAVector(), positionComponent.Position.ToXNAVector(),

View File

@ -17,8 +17,10 @@ using Encompass;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using PongFE.Messages; using PongFE.Messages;
public class InputEngine : Engine namespace PongFE.Engines
{ {
public class InputEngine : Engine
{
public override void Update(double dt) public override void Update(double dt)
{ {
var keyboardState = Keyboard.GetState(); var keyboardState = Keyboard.GetState();
@ -28,6 +30,7 @@ public class InputEngine : Engine
SendMessage(new MotionMessage( SendMessage(new MotionMessage(
} }
} }
}
} }
``` ```

View File

@ -11,12 +11,15 @@ Create a file: **PongFE/Engines/MotionEngine.cs**
```cs ```cs
using Encompass; using Encompass;
public class MotionEngine : Engine namespace PongFE.Engines
{ {
public class MotionEngine : Engine
{
public override void Update(double dt) public override void Update(double dt)
{ {
} }
}
} }
``` ```
@ -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. 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 ```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 ```cs
... ...
WorldBuilder.AddEngine(new MotionEngine());
WorldBuilder.AddOrderedRenderer(new Texture2DRenderer(SpriteBatch)); WorldBuilder.AddOrderedRenderer(new Texture2DRenderer(SpriteBatch));
... ...
``` ```