Print Page | Close Window

Day night code, Nice bluish one

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=211
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Day night code, Nice bluish one
Posted By: Sync
Subject: Day night code, Nice bluish one
Date Posted: 11 February 2006 at 3:35pm
This isnt the fastest way too do it, but it looks alot better than an old plain net over everything.

Add thost on top of the DirectX mod you know here

Public DD_nightSurf As DirectDrawSurface7



Public DDSD_Night As DDSURFACEDESC2


Then add this among the others in the Initsurface sub (still modDirectx)



    ' Init nights ddsd type and load the bitmap
    DDSD_Night.lFlags = DDSD_CAPS
    DDSD_Night.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
    Set DD_nightSurf = DD.CreateSurfaceFromFile(App.Path & "\night.bmp", DDSD_Night)
     DD_nightSurf.SetColorKey DDCKEY_SRCBLT, key


And in the sub under that one add

Set DD_nightSurf = Nothing


Then at the buttom of modDirectX add this sub

Sub DisplayFx(ByRef surfDisplay As DirectDrawSurface7, intX As Integer, intY As Integer, intWidth As Integer, intHeight As Integer, lngROP As Long, blnFxCap As Boolean)

Dim rectSource As RECT
Dim lngSrcDC As Long
Dim lngDestDC As Long


    With rectSource
        'Set and clip
        .top = 200
        .Bottom = 0
        .Left = 200
        .Right = 0
    End With
    
        lngDestDC = DD_BackBuffer.GetDC
        lngSrcDC = surfDisplay.GetDC
        'Do the fancy old-fashioned blit
        BitBlt lngDestDC, intX, intY, intWidth, intHeight, lngSrcDC, 0, 0, lngROP
        'Release our DCs
        surfDisplay.ReleaseDC lngSrcDC
        DD_BackBuffer.ReleaseDC lngDestDC
End Sub


Then this at the end of modGamelogic so you may find it easy

Sub Night()
 DisplayFx DD_nightSurf, 0, 0, 640, 480, vbSrcAnd, DDBLT_ROP Or DDBLT_WAIT
 End Sub

The 640, 480, are the width and height of the Night.bmp
Right now it just loads a bitmap untop of everything, if you like you may make it much more advanced buy make it blt small tiles and special tiles around lights and such (adding it as a layer in the mapeditor). But Im just too lazy too show you all that and I think im already quite generous.


        'THIS HAS TO LIE UNDER BLIT OUT THE FRINGE LAYER, blit out the night thing
        Call Night

Add this under the

        ' Blit out tile layer fringe
        For Y = 0 To MAX_MAPY
             For X = 0 To MAX_MAPX
                 Call BltFringeTile(X, Y)
             Next X
        Next Y
       

And this just blits the night layer out, its no timer or anything but there are other tutorials that makes /night comands and such.
If you already have some timer just add something like
Sub Night()
If TIME_NIGHT = 1 Then
 DisplayFx DD_nightSurf, 0, 0, 640, 480, vbSrcAnd, DDBLT_ROP Or DDBLT_WAIT
End If
 End Sub

Dont forget too add this file in the client folder
http://cc.1asphost.com/Divinitus/night.bmp - http://cc.1asphost.com/Divinitus/night.bmp
And this is what it looks like




Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info