Time for action – accounting for walls
Add the
checkTileObstacles()
method to theMovement
Limitations
region of thePlayer
module:Public Function checkTileObstacles( elapsedTime As Single, moveAngle As Vector2) As Vector2 Dim newHorizontalLocation As Vector2 = BaseSprite.WorldLocation + (New Vector2(moveAngle.X, 0) * (playerSpeed * elapsedTime)) Dim newVerticalLocation As Vector2 = BaseSprite.WorldLocation + (New Vector2(0, moveAngle.Y) * (playerSpeed * elapsedTime)) Dim newHorizontalRect As Rectangle = new Rectangle( CInt(Int(newHorizontalLocation.X)), CInt(Int(BaseSprite.WorldLocation.Y)), BaseSprite.FrameWidth, BaseSprite.FrameHeight) Dim newVerticalRect As Rectangle = new Rectangle( CInt(Int(BaseSprite.WorldLocation.X)), CInt(Int(newVerticalLocation.Y)), BaseSprite.FrameWidth, BaseSprite.FrameHeight) Dim horizLeftPixel As Integer = 0 Dim horizRightPixel As Integer = 0 Dim vertTopPixel As Integer = 0 Dim vertBottomPixel As Integer...