Showing Up Char

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

Iceplug
07-27-2002, 05:41 AM
Is the entire character not showing up, or is just the body visible?

Chazz569
07-27-2002, 08:30 AM
code successfuly display the main character, but i dunnno how to edit it so it can display a second 1

Iceplug
07-27-2002, 08:46 AM
It shows the entire character with head and body, but it doesn't show a duplicate?

Seems like this line
Call GetPlayerPosReMap(x, y)

along with the BodyRECT & HeadRECT need to be updated.

Chazz569
07-27-2002, 09:44 AM
i've replaced the call get player by the exact location i when them and i have copy, pasted and changed head and body and their declaration to head2 body2, bu. it it still doesn't show u. Here what i got so far BodyRECT2.left = 0
BodyRECT2.Right = 38
BodyRECT2.top = 0
BodyRECT2.Bottom = 43
HeadRECT2.left = 0
HeadRECT2.Right = 32
HeadRECT2.top = 0
HeadRECT2.Bottom = 32
On Error GoTo label123
DDCreateSurface Head2, App.Path & "\Characters\" & NpcDataSplitter(3) & "-Head.gfx", HeadRECT2 'creates surface to hold the players head
DDCreateSurface Body2, App.Path & "\Characters\" & NpcDataSplitter(3) & "-Body.gfx", BodyRECT2 'creates surface to hold the players body
BodyRECT2.left = ((frame * PlayerData.BodyWidth) - PlayerData.BodyWidth)
BodyRECT2.Right = (frame * PlayerData.BodyWidth)
HeadRECT2.top = ((frame * PlayerData.HeadHeight) - PlayerData.HeadHeight)
HeadRECT2.Bottom = (frame * PlayerData.HeadHeight)
BltPlayer2 Body2, BodyRECT2, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT 'puts the body image at the players x and y coords
BltPlayer2 Head2, HeadRECT2, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT, 3, -21 'places the head a little about the x and y coords
End If
Exit Sub
label123:
DebugIt (Err.Description & " " & NpcDataSplitter(3) & " " & Data)
End Sub
Public Function DebugIt(message As String)
Dim j
j = FreeFile
Open App.Path & "\debug.txt" For Output As #j
Print #j, message
Close #j
End Function
Public Sub BltPlayer2(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
On Error GoTo label123
'Call GetPlayerPosReMap(NpcX, NpcY)
'NpcX = NpcX + xOffset: NpcY = NpcY + 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 NpcX <= 0 Then SrcRect.left = SrcRect.left - NpcX
'If (NpcX + SrcRect.Right - SrcRect.left) >= 640 Then _
'SrcRect.Right = SrcRect.left + (640 - NpcX)
'NpcX = IIf(NpcX < 0, 0, NpcX)

'Here we check if the persons too far right and adjust
'If NpcY <= 0 Then SrcRect.top = SrcRect.top - NpcY
'If (NpcY + SrcRect.Bottom - SrcRect.top) >= 480 Then _
'SrcRect.Bottom = SrcRect.top + (480 - NpcY)
'NpcY = IIf(NpcY < 0, 0, NpcY)

'Blt the whole thing
DebugIt (NpcX & NpcY)
ddsBackBuffer2.BltFast NpcX, NpcY, surf, SrcRect, trans

'Then copy rect rect back over
SrcRect = temprect
Exit Sub
label123:
DebugIt (Err.Description & " " & NpcDataSplitter(3) & " " & Data)
End Sub

Iceplug
07-27-2002, 10:55 AM
Did you set the color key to the surface DDCKEY_SRCBLT?

It's hard to see without all of the code. Perhaps you should attach it, please.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum