Many thanks for these tutorials!
However, I encountered a few confusing problems...
In Tutorial 4 - Adding the Player Entity:
// Player.cs
// These lines give an error and wont compile because the third parameter has to be a float
sprite.Add("standLeft", new int[] { 0, 1 }, new int[] { 10, 10 });
// I changed it to the following, which seemed to work:
sprite.Add("standLeft", new int[] { 0, 1 }, new float[] { 10f, 10f });
I also got confused by the paragraph below:
Next, we must check if these keys are being pressed in the Player.cs class, and handle the input accordingly. We must also play the proper animation in our spritesheet, that corresponds with the current input. This is all done in our Update method, which you should modify to look like so:
It was confusing because the Player.cs class did not already have an Update() method defined. It might be clearer to use the word "create" instead of "modify".
Running the tutorial does not work - no bullets are fired. After I downloaded the complete source code for this tutorial, I found that there was more code that was not mentioned within the tutorial:
// Player.cs
public int direction = 0; // tutorial text does not mention this required line
public Player(float x = 0, float y = 0)
{
direction = Global.DIR_DOWN; // tutorial text does not mention this required line
Also, in the Player.cs Update method, the direction needs to be set for each key:
// Player.cs
public override void Update()
{
if (Global.PlayerSession.Controller.Left.Down)
{
X -= moveSpeed;
sprite.Play("walkLeft");
sprite.FlippedX = true;
direction = Global.DIR_LEFT; // tutorial text does not mention this required line
}
Also the tutorial text does not mention that the following code needs to be added to the Player.cs Update method:
if (Global.PlayerSession.Controller.X.Pressed)
{
Global.TUTORIAL.Scene.Add(new Bullet(X, Y, direction));
}
Finally, when adding the game scene music, the tutorial text says to add a line of code to "Global.cs", which is incorrect. The code actually needs to be added to "Assets.cs":
public const string MUSIC_GAME = "../../Assets/Music/game.ogg";
It would be helpful if these mistakes could be corrected. Thanks again
One final point - the player can move in 8 directions but the bullet can only shoot in 4 directions...