Time for action – building the GameObject class – part 3
Add the map-based collision detection methods to the
GameObject
class:#Region "Map-Based Collision Detection Methods" Private Function horizontalCollisionTest( moveAmount As Vector2) As Vector2 If moveAmount.X = 0 Then Return moveAmount End If Dim afterMoveRect As Rectangle = CollisionRectangle afterMoveRect.Offset(CInt(moveAmount.X),0) Dim corner1 As Vector2 Dim corner2 As Vector2 If moveAmount.X < 0 Then corner1 = New Vector2(afterMoveRect.Left, afterMoveRect.Top + 1) corner2 = New Vector2(afterMoveRect.Left, afterMoveRect.Bottom - 1) Else corner1 = New Vector2(afterMoveRect.Right, afterMoveRect.Top + 1) corner2 = New Vector2(afterMoveRect.Right, afterMoveRect.Bottom - 1) End If Dim mapCell1 As Vector2 = TileMap.GetCellByPixel...