@@ -660,28 +660,28 @@ Open the *Game1.cs* file and perform the following:
660
660
661
661
3 . Finally , after creating the bounding rectangle for the circle, add the following to perform a distance based collision check:
662
662
663
- ```cs
664
- // Use distance based checks to determine if the slime is within the
665
- // bounds of the game screen, and if it's outside that screen edge,
666
- // move it back inside.
667
- if(slimeBounds.Left < screenBounds.Left)
668
- {
669
- _slimePosition .X = screenBounds .Left ;
670
- }
671
- else if (slimeBounds .Right > screenBounds .Right )
672
- {
673
- _slimePosition .X = screenBounds .Right - _slime .Width ;
674
- }
675
-
676
- if (slimeBounds .Top < screenBounds .Top )
677
- {
678
- _slimePosition .Y = screenBounds .Top ;
679
- }
680
- else if (slimeBounds .Bottom > screenBounds .Bottom )
681
- {
682
- _slimePosition .Y = screenBounds .Bottom - _slime .Height ;
683
- }
684
- ```
663
+ ```cs
664
+ // Use distance based checks to determine if the slime is within the
665
+ // bounds of the game screen, and if it's outside that screen edge,
666
+ // move it back inside.
667
+ if(slimeBounds.Left < screenBounds.Left)
668
+ {
669
+ _slimePosition .X = screenBounds .Left ;
670
+ }
671
+ else if (slimeBounds .Right > screenBounds .Right )
672
+ {
673
+ _slimePosition .X = screenBounds .Right - _slime .Width ;
674
+ }
675
+
676
+ if (slimeBounds .Top < screenBounds .Top )
677
+ {
678
+ _slimePosition .Y = screenBounds .Top ;
679
+ }
680
+ else if (slimeBounds .Bottom > screenBounds .Bottom )
681
+ {
682
+ _slimePosition .Y = screenBounds .Bottom - _slime .Height ;
683
+ }
684
+ ```
685
685
686
686
Running the game now , try moving the slime outside the edges of the game window . You 'll see that it' s now being prevented from doing so :
687
687
0 commit comments