I am trying to trace the StarWarrior
code (the Artemis tutorial). I cannot figure out how these sprites are being drawn. This is the code where the player's ship is initialized:
/// <summary>The initialize player ship.</summary>
private void InitializePlayerShip()
{
Entity entity = this.entityWorld.CreateEntity();
entity.Group = "SHIPS";
entity.AddComponentFromPool<TransformComponent>();
entity.AddComponent(new SpatialFormComponent("PlayerShip"));
entity.AddComponent(new HealthComponent(30));
entity.GetComponent<TransformComponent>().X = this.GraphicsDevice.Viewport.Width * 0.5f;
entity.GetComponent<TransformComponent>().Y = this.GraphicsDevice.Viewport.Height - 50;
entity.Tag = "PLAYER";
}
Which line of code actually leads to the ship being drawn? The drawing takes place in PlayerShip.cs
. Here is a commented version of the code with what I think is happening:
/// <summary>The initialize player ship.</summary>
private void InitializePlayerShip()
{
Entity entity = this.entityWorld.CreateEntity(); //declare and initialize entity
entity.Group = "SHIPS"; //Unused label
entity.AddComponentFromPool<TransformComponent>(); //Add the component to store X and Y
entity.AddComponent(new SpatialFormComponent("PlayerShip")); //Add a component which is just a String (perhaps this has something to do with PlayerShip.cs?)
entity.AddComponent(new HealthComponent(30)); //Add a health component with 30 hp
entity.GetComponent<TransformComponent>().X = this.GraphicsDevice.Viewport.Width * 0.5f; //Initialize the TransformComponent's X
entity.GetComponent<TransformComponent>().Y = this.GraphicsDevice.Viewport.Height - 50; //Initialize the TransformComponent's Y
entity.Tag = "PLAYER"; //Unused label
}
So how is the actual sprite being drawn? Because, I am not seeing it. :(
If it is being drawn by entityWorld.Draw()
in the Draw()
method, then which line(s) of code put it in the world to be drawn? Or what is actually happening in entityWorld.Draw()
?
I believe the RenderSystem
is the one that is doing the drawing, but I don't get how it is being called.
I am sorry for the uninformed question, but I have made no progress after about 12 hours, and I desperately need some guidance!