Chazz569
07-26-2002, 11:29 PM
I'm trying to display a second character for a DX game editing the copy and paste code for the sub to show the main character. Allthought i relly can't figure how to display the character @ the right x and y. I've been working on it for 3 hours and a half stair and can't figure out so I'm posting here, here the code:
Public Sub DrawPlayerData()
'line to display character
BltPlayer Body, BodyRECT, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT 'puts the body image at the players x and y coords
BltPlayer Head, HeadRECT, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT, 3, -21 'places the head a little about the x and y coords
End Sub
Public Sub BltPlayer(ByRef surf As DirectDrawSurface7, ByRef SrcRect As RECT, _
ByVal trans As CONST_DDBLTFASTFLAGS, Optional xOffset As Single, Optional yOffset As Single)
Dim x As Single, y As Single
Dim temprect As RECT
Call GetPlayerPosReMap(x, y)
x = x + xOffset: y = y + yOffset
temprect = SrcRect 'because we can't pass rects byval _
we need to store it to reset it later on
'Here we check if the persons too far left and adjust
If x <= 0 Then SrcRect.left = SrcRect.left - x
If (x + SrcRect.Right - SrcRect.left) >= 640 Then _
SrcRect.Right = SrcRect.left + (640 - x)
x = IIf(x < 0, 0, x)
'Here we check if the persons too far right and adjust
If y <= 0 Then SrcRect.top = SrcRect.top - y
If (y + SrcRect.Bottom - SrcRect.top) >= 480 Then _
SrcRect.Bottom = SrcRect.top + (480 - y)
y = IIf(y < 0, 0, y)
'Blt the whole thing
ddsBackBuffer.BltFast x, y, surf, SrcRect, trans
'Then copy rect rect back over
SrcRect = temprect
End Sub
Any help is greatly appresiated
Public Sub DrawPlayerData()
'line to display character
BltPlayer Body, BodyRECT, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT 'puts the body image at the players x and y coords
BltPlayer Head, HeadRECT, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT, 3, -21 'places the head a little about the x and y coords
End Sub
Public Sub BltPlayer(ByRef surf As DirectDrawSurface7, ByRef SrcRect As RECT, _
ByVal trans As CONST_DDBLTFASTFLAGS, Optional xOffset As Single, Optional yOffset As Single)
Dim x As Single, y As Single
Dim temprect As RECT
Call GetPlayerPosReMap(x, y)
x = x + xOffset: y = y + yOffset
temprect = SrcRect 'because we can't pass rects byval _
we need to store it to reset it later on
'Here we check if the persons too far left and adjust
If x <= 0 Then SrcRect.left = SrcRect.left - x
If (x + SrcRect.Right - SrcRect.left) >= 640 Then _
SrcRect.Right = SrcRect.left + (640 - x)
x = IIf(x < 0, 0, x)
'Here we check if the persons too far right and adjust
If y <= 0 Then SrcRect.top = SrcRect.top - y
If (y + SrcRect.Bottom - SrcRect.top) >= 480 Then _
SrcRect.Bottom = SrcRect.top + (480 - y)
y = IIf(y < 0, 0, y)
'Blt the whole thing
ddsBackBuffer.BltFast x, y, surf, SrcRect, trans
'Then copy rect rect back over
SrcRect = temprect
End Sub
Any help is greatly appresiated