Here's the way I normally do it, but you could wrap it all up into a function or something so you can easier re-use it...
This is untested btw, so it might have a little error in it...Code:Dim rScreen As Rect Dim rSource As Rect Dim lX As Long Dim lY As Long ' At initialization, we Set up the screen rectangle ' (also used For BltColorFill To clear the backbuffer) With rScreen .Left = 0 .Top = 0 .Right = 640 .Bottom = 480 End With ' Now when we want To blit, we calculate the X And Y ' values And the source rectangle As normally... ' Just some random values here In this case... lX = -4 lY = 470 With rSource .Left = 0 .Top = 0 .Right = .Left + 256 .Bottom = .Top + 256 End With ' Then, Do some clipping! If lX < 0 Then ' Adjust the rectangle And the X coordinate rSource.Left = -lX lX = 0 End If If lY < 0 Then ' Adjust the rectangle And the Y coordinate rSource.Top = -lY lY = 0 End If If lX > rScreen.Right Then ' Adjust the rectangle rSource.Right = rScreen.Right - lX End If If lY > rScreen.Bottom Then ' Adjust the rectangle rSource.Bottom = rScreen.Bottom - lY End If ' Then just blit it As normally, using the X And Y values ' And the rectangle which is modified above...




Reply With Quote