Skip to content

Commit 598bed0

Browse files
Merge pull request #97 from AristurtleDev/fix/normalize-vector
Normalize vector before reflecting for bat bounce.
2 parents 1793359 + aa43bac commit 598bed0

16 files changed

Lines changed: 28 additions & 0 deletions

File tree

  • Tutorials/learn-monogame-2d/src
    • 12-Collision-Detection/DungeonSlime
    • 13-Tilemap/DungeonSlime
    • 14-SoundEffects-And-Music/DungeonSlime
    • 15-Audio-Controller/DungeonSlime
    • 16-Working-With-SpriteFonts/DungeonSlime
    • 17-Scenes/DungeonSlime/Scenes
    • 18-Texture-Wrapping/DungeonSlime/Scenes
    • 19-User-Interface-Fundamentals/DungeonSlime/Scenes
    • 20-Implementing-UI-With-Gum/DungeonSlime/Scenes
    • 21-Customizing-Gum-UI/DungeonSlime/Scenes
    • 22-Snake-Game-Mechanics/DungeonSlime/GameObjects
    • 23-Completing-The-Game/DungeonSlime/GameObjects
    • 24-Shaders/DungeonSlime/GameObjects
    • 25-Packaging-Game/DungeonSlime/GameObjects
    • 26-Publish-To-Itch/DungeonSlime/GameObjects
    • 27-Conclusion/DungeonSlime/GameObjects

Tutorials/learn-monogame-2d/src/12-Collision-Detection/DungeonSlime/Game1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ protected override void Update(GameTime gameTime)
151151
// normal.
152152
if (normal != Vector2.Zero)
153153
{
154+
normal.Normalize();
154155
_batVelocity = Vector2.Reflect(_batVelocity, normal);
155156
}
156157

Tutorials/learn-monogame-2d/src/13-Tilemap/DungeonSlime/Game1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ protected override void Update(GameTime gameTime)
166166
// normal.
167167
if (normal != Vector2.Zero)
168168
{
169+
normal.Normalize();
169170
_batVelocity = Vector2.Reflect(_batVelocity, normal);
170171
}
171172

Tutorials/learn-monogame-2d/src/14-SoundEffects-And-Music/DungeonSlime/Game1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ protected override void Update(GameTime gameTime)
195195
// normal.
196196
if (normal != Vector2.Zero)
197197
{
198+
normal.Normalize();
198199
_batVelocity = Vector2.Reflect(_batVelocity, normal);
199200

200201
// Play the bounce sound effect

Tutorials/learn-monogame-2d/src/15-Audio-Controller/DungeonSlime/Game1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ protected override void Update(GameTime gameTime)
189189
// normal.
190190
if (normal != Vector2.Zero)
191191
{
192+
normal.Normalize();
192193
_batVelocity = Vector2.Reflect(_batVelocity, normal);
193194

194195
// Play the bounce sound effect

Tutorials/learn-monogame-2d/src/16-Working-With-SpriteFonts/DungeonSlime/Game1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ protected override void Update(GameTime gameTime)
213213
// normal.
214214
if (normal != Vector2.Zero)
215215
{
216+
normal.Normalize();
216217
_batVelocity = Vector2.Reflect(_batVelocity, normal);
217218

218219
// Play the bounce sound effect

Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public override void Update(GameTime gameTime)
203203
// normal.
204204
if (normal != Vector2.Zero)
205205
{
206+
normal.Normalize();
206207
_batVelocity = Vector2.Reflect(_batVelocity, normal);
207208

208209
// Play the bounce sound effect

Tutorials/learn-monogame-2d/src/18-Texture-Wrapping/DungeonSlime/Scenes/GameScene.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public override void Update(GameTime gameTime)
203203
// normal.
204204
if (normal != Vector2.Zero)
205205
{
206+
normal.Normalize();
206207
_batVelocity = Vector2.Reflect(_batVelocity, normal);
207208

208209
// Play the bounce sound effect

Tutorials/learn-monogame-2d/src/19-User-Interface-Fundamentals/DungeonSlime/Scenes/GameScene.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public override void Update(GameTime gameTime)
203203
// normal.
204204
if (normal != Vector2.Zero)
205205
{
206+
normal.Normalize();
206207
_batVelocity = Vector2.Reflect(_batVelocity, normal);
207208

208209
// Play the bounce sound effect

Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/GameScene.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ public override void Update(GameTime gameTime)
300300
// normal.
301301
if (normal != Vector2.Zero)
302302
{
303+
normal.Normalize();
303304
_batVelocity = Vector2.Reflect(_batVelocity, normal);
304305

305306
// Play the bounce sound effect

Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/GameScene.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ public override void Update(GameTime gameTime)
314314
// normal.
315315
if (normal != Vector2.Zero)
316316
{
317+
normal.Normalize();
317318
_batVelocity = Vector2.Reflect(_batVelocity, normal);
318319

319320
// Play the bounce sound effect

0 commit comments

Comments
 (0)