Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transparent Color For Surfaces
#1
Author: Enigmewave
Difficulty: 3/5

:: CLIENT SIDE ::
In modDirectX.bas, add:
Code:
Public Sub SetMaskColorFromPixel(ByRef TheSurface As DirectDrawSurface7, ByVal X As Long, ByVal Y As Long)
Dim TmpR As RECT
Dim TmpDDSD As DDSURFACEDESC2
Dim TmpColorKey As DDCOLORKEY

With TmpR
        .Left = X
        .Top = Y
        .Right = X
        .Bottom = Y
End With

TheSurface.Lock TmpR, TmpDDSD, DDLOCK_WAIT Or DDLOCK_READONLY, 0

With TmpColorKey
        .low = TheSurface.GetLockedPixel(X, Y)
        .high = .low
End With

TheSurface.SetColorKey DDCKEY_SRCBLT, TmpColorKey

TheSurface.Unlock TmpR
End Sub

In sub InitSurfaces, replace:
Code:
DD_SpriteSurf.SetColorKey DDCKEY_SRCBLT, key
With:
Code:
SetMaskColorFromPixel DD_SpriteSurf, 0, 0
Replace:
Code:
DD_TileSurf.SetColorKey DDCKEY_SRCBLT, key
With:
Code:
SetMaskColorFromPixel DD_TileSurf, 0, 0
Replace:
Code:
DD_ItemSurf.SetColorKey DDCKEY_SRCBLT, key
With:
Code:
SetMaskColorFromPixel DD_ItemSurf, 0, 0

After that, whatever color the top left pixel is on the sprites surface, tiles surface, or items surface will be the transparent color for that surface.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)