diff --git a/articles/tutorials/building_2d_games/12_collision_detection/index.md b/articles/tutorials/building_2d_games/12_collision_detection/index.md index d8a25f19..8c6e5b9e 100644 --- a/articles/tutorials/building_2d_games/12_collision_detection/index.md +++ b/articles/tutorials/building_2d_games/12_collision_detection/index.md @@ -311,7 +311,7 @@ If you run the game right now and move the slime around, you will notice a few i We can now implement these features using collision detection and response in our game. In the *DungeonSlime* project (your main game project), open the `Game1.cs` file and make the following changes to the `Game1` class: -[!code-csharp[](./snippets/game1.cs?highlight=1,5,25-29,40-45,76–176,181–193,293–294)] +[!code-csharp[](./snippets/game1.cs?highlight=1,5,25-29,40-45,76–177,182–194,294–295)] The key changes made here are: diff --git a/articles/tutorials/building_2d_games/12_collision_detection/snippets/game1.cs b/articles/tutorials/building_2d_games/12_collision_detection/snippets/game1.cs index 38583747..d92dab21 100644 --- a/articles/tutorials/building_2d_games/12_collision_detection/snippets/game1.cs +++ b/articles/tutorials/building_2d_games/12_collision_detection/snippets/game1.cs @@ -151,6 +151,7 @@ protected override void Update(GameTime gameTime) // normal. if (normal != Vector2.Zero) { + normal.Normalize(); _batVelocity = Vector2.Reflect(_batVelocity, normal); } diff --git a/articles/tutorials/building_2d_games/13_working_with_tilemaps/index.md b/articles/tutorials/building_2d_games/13_working_with_tilemaps/index.md index 85751702..94eaacbb 100644 --- a/articles/tutorials/building_2d_games/13_working_with_tilemaps/index.md +++ b/articles/tutorials/building_2d_games/13_working_with_tilemaps/index.md @@ -186,7 +186,7 @@ This tilemap configuration creates a simple dungeon layout with walls around the With all of the assets now in place and configured, we can update the `Game1` class to load the tilemap and draw it. We will also need to update the collision logic so that the boundary is no longer the edge of the screen, but instead the edges of the wall tiles of the tilemap. Open `Game1.cs` and make the following updates: -[!code-csharp[](./snippets/game1.cs?highlight=31-35,46-61,80-82,109,111,113,125,118,120,122,124,142,145,147,150,153,156,158,161,176–178,300–301)] +[!code-csharp[](./snippets/game1.cs?highlight=31-35,46-61,80-82,109,111,113,125,118,120,122,124,142,145,147,150,153,156,158,161,177–179,301–302)] The key changes to the `Game1` class include: diff --git a/articles/tutorials/building_2d_games/13_working_with_tilemaps/snippets/game1.cs b/articles/tutorials/building_2d_games/13_working_with_tilemaps/snippets/game1.cs index 66e0e876..e5535c60 100644 --- a/articles/tutorials/building_2d_games/13_working_with_tilemaps/snippets/game1.cs +++ b/articles/tutorials/building_2d_games/13_working_with_tilemaps/snippets/game1.cs @@ -166,6 +166,7 @@ protected override void Update(GameTime gameTime) // normal. if (normal != Vector2.Zero) { + normal.Normalize(); _batVelocity = Vector2.Reflect(_batVelocity, normal); } diff --git a/articles/tutorials/building_2d_games/14_soundeffects_and_music/index.md b/articles/tutorials/building_2d_games/14_soundeffects_and_music/index.md index c32a5e54..8cddb9ae 100644 --- a/articles/tutorials/building_2d_games/14_soundeffects_and_music/index.md +++ b/articles/tutorials/building_2d_games/14_soundeffects_and_music/index.md @@ -175,7 +175,7 @@ Add these files to your content project using the MGCB Editor: Next, open the `Game1.cs` file and update it to the following: -[!code-csharp[](./snippets/game1.cs?highlight=3,6,39-43,92-111,200-201,219-220)] +[!code-csharp[](./snippets/game1.cs?highlight=3,6,39-43,92-111,201-202,220-221)] The key changes here are: diff --git a/articles/tutorials/building_2d_games/14_soundeffects_and_music/snippets/game1.cs b/articles/tutorials/building_2d_games/14_soundeffects_and_music/snippets/game1.cs index 24976e9b..9069610f 100644 --- a/articles/tutorials/building_2d_games/14_soundeffects_and_music/snippets/game1.cs +++ b/articles/tutorials/building_2d_games/14_soundeffects_and_music/snippets/game1.cs @@ -195,6 +195,7 @@ protected override void Update(GameTime gameTime) // normal. if (normal != Vector2.Zero) { + normal.Normalize(); _batVelocity = Vector2.Reflect(_batVelocity, normal); // Play the bounce sound effect diff --git a/articles/tutorials/building_2d_games/15_audio_controller/index.md b/articles/tutorials/building_2d_games/15_audio_controller/index.md index b526616b..3377697f 100644 --- a/articles/tutorials/building_2d_games/15_audio_controller/index.md +++ b/articles/tutorials/building_2d_games/15_audio_controller/index.md @@ -131,7 +131,7 @@ The key changes made here are: Next, update the `Game1` class to use the audio controller for audio playback. Open `Game1.cs` and make the following updates: -[!code-csharp[](./snippets/game1.cs?highlight=45-46,77-78,104-105,194–195,213–214,267–285)] +[!code-csharp[](./snippets/game1.cs?highlight=45-46,77-78,104-105,195–196,214–215,268–286)] > [!NOTE] > Note there were a lot of replacements in the `LoadContent` method, switching from loading and initializing the background Song and replacing it with a call to the new `AudioController` to do all the work managing the Song reference. Much cleaner. diff --git a/articles/tutorials/building_2d_games/15_audio_controller/snippets/game1.cs b/articles/tutorials/building_2d_games/15_audio_controller/snippets/game1.cs index bd5ddb66..3841f24c 100644 --- a/articles/tutorials/building_2d_games/15_audio_controller/snippets/game1.cs +++ b/articles/tutorials/building_2d_games/15_audio_controller/snippets/game1.cs @@ -189,6 +189,7 @@ protected override void Update(GameTime gameTime) // normal. if (normal != Vector2.Zero) { + normal.Normalize(); _batVelocity = Vector2.Reflect(_batVelocity, normal); // Play the bounce sound effect. diff --git a/articles/tutorials/building_2d_games/16_working_with_spritefonts/index.md b/articles/tutorials/building_2d_games/16_working_with_spritefonts/index.md index e0816ad5..01cfb681 100644 --- a/articles/tutorials/building_2d_games/16_working_with_spritefonts/index.md +++ b/articles/tutorials/building_2d_games/16_working_with_spritefonts/index.md @@ -217,7 +217,7 @@ The key changes here are: Finally, open the `Game1.cs` file and make the following changes: -[!code-csharp[](./snippets/game1.cs?highlight=48-58,93-99,129-130,240-241,385-396)] +[!code-csharp[](./snippets/game1.cs?highlight=48-58,93-99,129-130,241-242,386-397)] The key changes made are: diff --git a/articles/tutorials/building_2d_games/16_working_with_spritefonts/snippets/game1.cs b/articles/tutorials/building_2d_games/16_working_with_spritefonts/snippets/game1.cs index 97b32669..f0583f57 100644 --- a/articles/tutorials/building_2d_games/16_working_with_spritefonts/snippets/game1.cs +++ b/articles/tutorials/building_2d_games/16_working_with_spritefonts/snippets/game1.cs @@ -213,6 +213,7 @@ protected override void Update(GameTime gameTime) // normal. if (normal != Vector2.Zero) { + normal.Normalize(); _batVelocity = Vector2.Reflect(_batVelocity, normal); // Play the bounce sound effect. diff --git a/articles/tutorials/building_2d_games/17_scenes/snippets/gamescene.cs b/articles/tutorials/building_2d_games/17_scenes/snippets/gamescene.cs index d8c5f260..7a36c888 100644 --- a/articles/tutorials/building_2d_games/17_scenes/snippets/gamescene.cs +++ b/articles/tutorials/building_2d_games/17_scenes/snippets/gamescene.cs @@ -215,6 +215,7 @@ public override void Update(GameTime gameTime) // normal. if (normal != Vector2.Zero) { + normal.Normalize(); _batVelocity = Vector2.Reflect(_batVelocity, normal); // Play the bounce sound effect. diff --git a/articles/tutorials/building_2d_games/22_snake_game_mechanics/snippets/bat/bounce.cs b/articles/tutorials/building_2d_games/22_snake_game_mechanics/snippets/bat/bounce.cs index 87275f52..4a70d0b5 100644 --- a/articles/tutorials/building_2d_games/22_snake_game_mechanics/snippets/bat/bounce.cs +++ b/articles/tutorials/building_2d_games/22_snake_game_mechanics/snippets/bat/bounce.cs @@ -24,6 +24,9 @@ public void Bounce(Vector2 normal) // Apply the new position Position = newPosition; + // Normalize before reflecting + normal.Normalize(); + // Apply reflection based on the normal. _velocity = Vector2.Reflect(_velocity, normal);