LBS
May 9th, 2002, 01:45 PM
Public Sub LoadSprite(ByRef Sprite As DirectDrawSurface7, File As String, bWidth As Integer, bHeight As Integer, ColourKey As Integer)
Dim CKey As DDCOLORKEY
Dim ddsdNewSprite As DDSURFACEDESC2
'This routine loads sprites in the FObject file and sets their colour keys
ddsdNewSprite.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT 'Set the surface description to include the Capabilities, Width and Height
ddsdNewSprite.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN 'Set the surface's capabilities to be an offscreen surface
ddsdNewSprite.lWidth = bWidth 'Set the width of the surface
ddsdNewSprite.lHeight = bHeight 'Set the height of the surface
THIS? -> Set Sprite = dd.CreateSurfaceFromResource("", File, ddsdNewSprite) 'Load the bitmap from the resource file into the surface using the surface description
CKey.low = ColourKey 'Set the low value of the colour key
CKey.high = ColourKey 'and the high value (in this case they're the same because we're not using a range)
Sprite.SetColorKey DDCKEY_SRCBLT, CKey 'Set the sprites colourkey using the key just created
End Sub
Thanks
Dim CKey As DDCOLORKEY
Dim ddsdNewSprite As DDSURFACEDESC2
'This routine loads sprites in the FObject file and sets their colour keys
ddsdNewSprite.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT 'Set the surface description to include the Capabilities, Width and Height
ddsdNewSprite.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN 'Set the surface's capabilities to be an offscreen surface
ddsdNewSprite.lWidth = bWidth 'Set the width of the surface
ddsdNewSprite.lHeight = bHeight 'Set the height of the surface
THIS? -> Set Sprite = dd.CreateSurfaceFromResource("", File, ddsdNewSprite) 'Load the bitmap from the resource file into the surface using the surface description
CKey.low = ColourKey 'Set the low value of the colour key
CKey.high = ColourKey 'and the high value (in this case they're the same because we're not using a range)
Sprite.SetColorKey DDCKEY_SRCBLT, CKey 'Set the sprites colourkey using the key just created
End Sub
Thanks