diff --git a/content/pong/draw_paddle/texture_renderer.md b/content/pong/draw_paddle/texture_renderer.md index ed2cf81..4a9fcda 100644 --- a/content/pong/draw_paddle/texture_renderer.md +++ b/content/pong/draw_paddle/texture_renderer.md @@ -18,7 +18,7 @@ namespace PongFE.Renderers { public class Texture2DRenderer : OrderedRenderer { - 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(), diff --git a/content/pong/move_paddle/input_handling.md b/content/pong/move_paddle/input_handling.md index a491820..4ae04ee 100644 --- a/content/pong/move_paddle/input_handling.md +++ b/content/pong/move_paddle/input_handling.md @@ -17,15 +17,18 @@ using Encompass; using Microsoft.Xna.Framework.Input; using PongFE.Messages; -public class InputEngine : Engine +namespace PongFE.Engines { - public override void Update(double dt) + public class InputEngine : Engine { - var keyboardState = Keyboard.GetState(); - - if (keyboardState.IsKeyDown(Keys.Down)) + public override void Update(double dt) { - SendMessage(new MotionMessage( + var keyboardState = Keyboard.GetState(); + + if (keyboardState.IsKeyDown(Keys.Down)) + { + SendMessage(new MotionMessage( + } } } } diff --git a/content/pong/move_paddle/motion_engine.md b/content/pong/move_paddle/motion_engine.md index e2871ca..b8ea8ae 100644 --- a/content/pong/move_paddle/motion_engine.md +++ b/content/pong/move_paddle/motion_engine.md @@ -11,11 +11,14 @@ Create a file: **PongFE/Engines/MotionEngine.cs** ```cs using Encompass; -public class MotionEngine : Engine +namespace PongFE.Engines { - public override void Update(double dt) + public class MotionEngine : Engine { + 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. ```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)); ... ```