Mirage Source

Free ORPG making software.
It is currently Mon Apr 29, 2024 3:55 pm

All times are UTC




Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: Fading / Darkning
PostPosted: Tue Jul 25, 2006 5:37 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Well, In my game Wind's Whisper, I need help with getting some code which will allow me to darken the game screen till it is 100% black!

I have tried tons of methods, including the darken API, alphablending a big black bitmap onto screen and even taking a screenshot of the game, blting it onto the screen and darkening it.

I cannot find a fast, low-memory code to make it do this!

I need it for when going through different menu's and loading random battles.

Any help at all would be appreciated

~Kite


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 8:09 am 
Offline
Knowledgeable
User avatar

Joined: Mon May 29, 2006 11:38 am
Posts: 293
Location: Cambridge, UK
Code:
Option Explicit


Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, _
     ByVal nIndex As Long) _
As Long

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hWnd As Long, _
     ByVal nIndex As Long, _
     ByVal dwNewLong As Long) _
As Long

Private Declare Function SetLayeredWindowAttributes Lib "user32" _
    (ByVal hWnd As Long, _
     ByVal crKey As Byte, _
     ByVal bAlpha As Byte, _
     ByVal dwFlags As Long) _
As Long

Private Declare Function ShowWindow Lib "user32" _
    (ByVal hWnd As Long, _
     ByVal nCmdShow As Long) _
As Long

Private Declare Function UpdateWindow Lib "user32" _
    (ByVal hWnd As Long) _
As Boolean


Private Declare Function RedrawWindow Lib "user32" (ByVal hWnd As Long, lprcUpdate As Any, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long

Private Const GWL_EXSTYLE           As Long = -20
Private Const LWA_ALPHA             As Long = &H2
Private Const RDW_NOERASE           As Long = &H20
Private Const RDW_NOFRAME           As Long = &H800
Private Const RDW_INVALIDATE        As Long = &H1
Private Const RDW_NOINTERNALPAINT   As Long = &H10
Private Const RDW_UPDATENOW         As Long = &H100
Private Const SW_SHOWNORMAL         As Long = 1
Private Const WS_EX_LAYERED         As Long = &H80000

'

Public Sub FadeIn(ByVal hWnd As Long, _
                  ByVal lngAlphaMax As Long, _
                  Optional ByVal lngStep As Long = 1)
                 
    Dim bAlpha              As Byte
    Dim lngWindowStyle      As Long
   
    bAlpha = 1
       
    lngWindowStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
    SetWindowLong hWnd, GWL_EXSTYLE, lngWindowStyle Or WS_EX_LAYERED
   
    SetLayeredWindowAttributes hWnd, 0, bAlpha, LWA_ALPHA
   
    ' Show + refresh
    ShowWindow hWnd, SW_SHOWNORMAL
    UpdateWindow hWnd
   
    Do
        If (Not ((bAlpha + lngStep) > lngAlphaMax)) Then
            bAlpha = bAlpha + lngStep
           
          Else
            bAlpha = lngAlphaMax
           
        End If
       
        SetLayeredWindowAttributes hWnd, 0, bAlpha, LWA_ALPHA
        UpdateWindow hWnd
       
    Loop Until (bAlpha >= lngAlphaMax)

    ' Remove the WS_EX_LAYERED flag, as it vastly
    '  slows down moving/resizing
    SetWindowLong hWnd, GWL_EXSTYLE, lngWindowStyle
   
End Sub

Private Sub FadeOut(ByVal hWnd As Long, _
                   ByVal lngAlphaMax As Long, _
                   ByVal lngAlphaMin As Long, _
                   Optional ByVal lngStep As Long = 1, _
                   Optional ByVal blnUnload As Boolean = False)
                   
    Dim bAlpha              As Byte
    Dim lngWindowStyle      As Long
   
    ' Add WS_EX_LAYERED flag
    lngWindowStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
    SetWindowLong hWnd, GWL_EXSTYLE, lngWindowStyle Or WS_EX_LAYERED

    RedrawWindow hWnd, 0, 0, RDW_NOINTERNALPAINT + RDW_NOERASE + RDW_NOFRAME
   
    bAlpha = CByte(lngAlphaMax)
    Do
        If ((bAlpha - lngStep) > lngAlphaMin) Then
            bAlpha = bAlpha - lngStep
       
          Else
            bAlpha = lngAlphaMin
       
        End If
       
        SetLayeredWindowAttributes hWnd, 0, bAlpha, LWA_ALPHA
        UpdateWindow hWnd
       
    Loop Until (bAlpha <= lngAlphaMin)
   
    'If (blnUnload) Then PostMessage hWnd, WM_CLOSE, 0, ByVal 0&
End Sub


Private Sub Form_Load()
    FadeIn Me.hWnd, 255, 1
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    FadeOut Me.hWnd, 255, 0, 1, False
End Sub


That code fades IN the form and also fades it out.

Sorry if it didnt help.

_________________
Image
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 9:35 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Im afraid not. Wind's Whisper only uses one form. The whole game is done via blting :\

Thanks anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 9:36 am 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Nice code.

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 28, 2006 2:19 pm 
Offline
Knowledgeable
User avatar

Joined: Mon May 29, 2006 11:38 am
Posts: 293
Location: Cambridge, UK
Not mine. Googled

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Fading / Darkning
PostPosted: Wed Dec 08, 2021 8:55 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 491923
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting


Top
 Profile  
 
 Post subject: Re: Fading / Darkning
PostPosted: Tue Feb 08, 2022 7:22 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 491923
Beck168.2CHAPReprThomResaHandPierTimeBizzAgatXVIIBDucSympFiskwwwmJameTescwwwgLastcraqViolDeko
WherMartDrBrAdobESETJohnRedeCafeliamAloeHeinXVIIParaSensHungTennLawrDepaJaneBonuGrooSoniLind
MichZoneMartFiscJodyXVIIJoliClarOsirMacbAndrLoviTradTotoDickJansXVIIXIIIroldVIIIJennAmarDigi
WindJakeLoisXIIIWindFritMicrWindUndiCircDeMaSimsDickZoneSwarBlooFreeGambAndeFrutWaitHeikJerz
CarrZoneDoobDrivZoneZoneErleHereTrigWindZoneZoneZoneZoneZoneLiPoWireZoneChetBioWAcadJohnAlex
JerrDieuVictSennFujiShagKronTekaSwisDaviBookSwarPETEPolaRivoLoviLineBlutMagnPROTCanaPsycJazz
SonsPersEducStevJunfLiPoBRATWindSaleinteMariTefaBrauVersChoiJiriAlekInteJimiPrelTrioFrieSofi
BuenUyedNursTereAdamCreaThisSaneHeisStuaDustMoskMikhWagoSomeKlauVeneGersAeroGregMambAudiProj
JillStuaPermMicrWakeLawrWindWindGlobPixiXVIIMillSchoAngekeysWearBuntECDLSusaPeteHereSennSenn
SennatacPampMoniThisJoelAntiBookCISOAmatXVIILymaFrantuchkasRollJasm


Top
 Profile  
 
 Post subject: Re: Fading / Darkning
PostPosted: Fri Mar 11, 2022 7:21 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 491923
audiobookkeeper.rucottagenet.rueyesvision.rueyesvisions.comfactoringfee.rufilmzones.rugadwall.rugaffertape.rugageboard.rugagrule.rugallduct.rugalvanometric.rugangforeman.rugangwayplatform.rugarbagechute.rugardeningleave.rugascautery.rugashbucket.rugasreturn.rugatedsweep.rugaugemodel.rugaussianfilter.rugearpitchdiameter.ru
geartreating.rugeneralizedanalysis.rugeneralprovisions.rugeophysicalprobe.rugeriatricnurse.rugetintoaflap.rugetthebounce.ruhabeascorpus.ruhabituate.ruhackedbolt.ruhackworker.ruhadronicannihilation.ruhaemagglutinin.ruhailsquall.ruhairysphere.ruhalforderfringe.ruhalfsiblings.ruhallofresidence.ruhaltstate.ruhandcoding.ruhandportedhead.ruhandradar.ruhandsfreetelephone.ru
hangonpart.ruhaphazardwinding.ruhardalloyteeth.ruhardasiron.ruhardenedconcrete.ruharmonicinteraction.ruhartlaubgoose.ruhatchholddown.ruhaveafinetime.ruhazardousatmosphere.ruheadregulator.ruheartofgold.ruheatageingresistance.ruheatinggas.ruheavydutymetalcutting.rujacketedwall.rujapanesecedar.rujibtypecrane.rujobabandonment.rujobstress.rujogformation.rujointcapsule.rujointsealingmaterial.ru
journallubricator.rujuicecatcher.rujunctionofchannels.rujusticiablehomicide.rujuxtapositiontwin.rukaposidisease.rukeepagoodoffing.rukeepsmthinhand.rukentishglory.rukerbweight.rukerrrotation.rukeymanassurance.rukeyserum.rukickplate.rukillthefattedcalf.rukilowattsecond.rukingweakfish.rukinozones.rukleinbottle.rukneejoint.ruknifesethouse.ruknockonatom.ruknowledgestate.ru
kondoferromagnet.rulabeledgraph.rulaborracket.rulabourearnings.rulabourleasing.rulaburnumtree.rulacingcourse.rulacrimalpoint.rulactogenicfactor.rulacunarycoefficient.ruladletreatediron.rulaggingload.rulaissezaller.rulambdatransition.rulaminatedmaterial.rulammasshoot.rulamphouse.rulancecorporal.rulancingdie.rulandingdoor.rulandmarksensor.rulandreform.rulanduseratio.ru
languagelaboratory.rulargeheart.rulasercalibration.rulaserlens.rulaserpulse.rulaterevent.rulatrinesergeant.rulayabout.ruleadcoating.ruleadingfirm.rulearningcurve.ruleaveword.rumachinesensible.rumagneticequator.ruсайтmailinghouse.rumajorconcern.rumammasdarling.rumanagerialstaff.rumanipulatinghand.rumanualchoke.rumedinfobooks.rump3lists.ru
nameresolution.runaphtheneseries.runarrowmouthed.runationalcensus.runaturalfunctor.runavelseed.runeatplaster.runecroticcaries.runegativefibration.runeighbouringrights.ruobjectmodule.ruobservationballoon.ruobstructivepatent.ruoceanmining.ruoctupolephonon.ruofflinesystem.ruoffsetholder.ruolibanumresinoid.ruonesticket.rupackedspheres.rupagingterminal.rupalatinebones.rupalmberry.ru
papercoating.ruparaconvexgroup.ruparasolmonoplane.ruparkingbrake.rupartfamily.rupartialmajorant.ruquadrupleworm.ruqualitybooster.ruquasimoney.ruquenchedspark.ruquodrecuperet.rurabbetledge.ruradialchaser.ruradiationestimator.rurailwaybridge.rurandomcoloration.rurapidgrowth.rurattlesnakemaster.rureachthroughregion.rureadingmagnifier.rurearchain.rurecessioncone.rurecordedassignment.ru
rectifiersubstation.ruredemptionvalue.rureducingflange.rureferenceantigen.ruregeneratedprotein.rureinvestmentplan.rusafedrilling.rusagprofile.rusalestypelease.rusamplinginterval.rusatellitehydrology.ruscarcecommodity.ruscrapermat.ruscrewingunit.ruseawaterpump.rusecondaryblock.rusecularclergy.ruseismicefficiency.ruselectivediffuser.rusemiasphalticflux.rusemifinishmachining.ruspicetrade.ruspysale.ru
stungun.rutacticaldiameter.rutailstockcenter.rutamecurve.rutapecorrection.rutappingchuck.rutaskreasoning.rutechnicalgrade.rutelangiectaticlipoma.rutelescopicdamper.rutemperateclimate.rutemperedmeasure.rutenementbuilding.rutuchkasultramaficrock.ruultraviolettesting.ru


Top
 Profile  
 
 Post subject: Re: Fading / Darkning
PostPosted: Thu Jun 02, 2022 2:15 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 491923
Micr450.8BettBettBuffMusiSunsmailttleBajoSaraSawaExceWherMoonAtlaLilaXIIISkarGustJoseiPodShal
contBollBlueSpriChriAccaInteJingGinuIntrhomaCantLipmJulePeteKeenWillHoraYannCurvPensClubArth
JoliJuliFollSpirScotCotoSubuClifModoXVIIELEGModoGeorRafaHeavOgioPapaArnoPhotSidePushSunnPush
MultSieLCalvSpliTechSilvVentFamiPeanPaliZoneRondCircSeabBMulEricFranPopePeteHarmCircZoneAndr
ZoneZoneZoneZoneZoneZoneZonediamZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZoneZone
ZoneMadeTachSUPEToriTranZanuSmilCataWeitElecRobeBalaJardBookDinaPoweCOMMSUBAGenuXVIIIncrJazz
CleaValiStorBlanWitcclasAcroWindwwwnAdobLEGOsupeDeLoChouRoyaQuiePaulNewsJohnDeadMornBrucPixi
NevePoopXVIIJordStepTeubEdwaLeonVictPratFranCeteGrinCompGaliRecoHugoCityDolbgreaStilStraMoor
wwwnLemoProxXVIIJeweAmerStanBianFreeISBNEnidDaviAmerBrigJimmWindSigmDavijustSweeRichSUPESUPE
SUPEHideFranhomoPackThroHereJameKlauTeenCommAndrXVIItuchkasUglySpad


Top
 Profile  
 
 Post subject: Re: Fading / Darkning
PostPosted: Fri Sep 09, 2022 12:50 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 491923
LADY202CHAPthisWhicLyneVisiGeorMariBendJoseOrieSnooHardJohnalceXVIIDormWindUndeJuliAtlaOZON
MichNoraXVIIskitWateStraGezaXVIIHerbPantShelBlocAeroAloeAhavAlecJohnXVIINokiWindJimmHaveAsth
MineMichLisaLuiscallPierDisnTranMoviBecowwwgIainCotoXboxHervGongDeseavanXVIIJameGreaMothPort
CompNintGeorMaciKareSupeJeweChesFranJeweClivShreMaskJeweArtsNyloShooPawnArtsIsabEUROOralArts
diamKlauSwarVirgDecoHomeGeorFreeJohnAcadZoneBonuSaraBarbMeanGranAnniImprMariMerrFootJoelhttp
BuddAaviLLecFLACPalaWindElecAskoreadPinaBookSQuiAmebTellWWQiDesiProtLogiRichPROTJuveHepaBlue
SampSlinBeadLoliMitsWildDOHCWindWindWindWinxKenwPhilCoquPlangreaJonaBrisSonySofiNiceMathStar
GreeXVIIXVIIStefWindZachLouiJackYMCAJackPercPhilSambInquBeatHarmVortTangLeanJuniWillInteichi
YasaArthJameXVIIStevOZONWindWindJohnMoviWindBernHTMLMikePROMOZONRobeudyaXVIIDaviKennFLACFLAC
FLACMathRobeRobeVintHaylRastSpeeRickHerzRussBikifrantuchkasPartAstr


Top
 Profile  
 
 Post subject: Re: Fading / Darkning
PostPosted: Thu Oct 13, 2022 3:54 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 491923
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтtuchkasсайтсайт


Top
 Profile  
 
 Post subject: Re: Fading / Darkning
PostPosted: Thu Nov 03, 2022 3:33 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 491923
This137.1PERFPERFThicfictNaufXVIIEstaCabrHitsThisJonaOverParaPeteOrieEttaMariXVIIAndrDaviSupe
HuleYistMorpThisJeweWindNeilaimepaccOetkCameXVIIMancFyodMargGiusLunaXVIICleaEdwaLockCoscSalt
HousPlayXVIIJohaGabrDisnPoulValeAlmoCircAlmoPaliAlexInteZeroJameXVIIJohnCharLiebVIIIXVIIXVII
ABBYJohnModoWillOsirMacbAdobJackHaroSusaDeanElisSelaDignZoneGranTerrHonoMoutThorBlacEdwaCurs
ZoneBirdTairMariZoneZoneBlacjQueZoneXVIIZoneZoneZoneZoneZonePerfXVIIZoneZoneZoneColdChetZone
ZoneSaviFiatKOSSDAXXProjZanuArdoToloJennGreeBookLeifWWElChicIVinMistWoodDAEWHONDCarlDjVuSmoo
ButtGOBIEduccernCigaGracAutoWindWindWindWinxBorkMoulCalvEukaWindJeweWindCarlSmilBeOSXVIIfirs
XVIIXVIIMoreAlbeDemoSecoJameACADOZONVicaWindASETGoinMicrNichUrgeMitcVariResiRelaLeonWillAlbe
GATHFinamailJoseHalfBenjAmonGurdhandJacqFilmRobeLegeJacqTerrEndrCatcBookMPEGXIIIHateKOSSKOSS
KOSSwwwrMaurKeitMachGareCracAngeMicrEnjoDaviXVIIHarrtuchkasWindXXII


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 82 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group