# Visual Basic > Games and Graphics Programming > Game Demos >  World of Warcraft Spell Cooldown Effect [VB.Net 2008, 2010 & VB6][DirectX]

## Jacob Roman

I had this code for quite sometime, and it was a royal pain to figure it out on my own. Because there is no source code on the internet other than mine that reveals this effect. For those who havent played World of Warcraft, your user interface that has a bunch of attacks, spells, and/or healing ability icons. When you click on one, depending on the ability, itll do one of two things. Either do a global cooldown, which prevents you from pressing any icon for a fraction of a second, or do that as well as put that ability on a cooldown for a certain duration of time. As its on cooldown, regardless of the type of cooldown, the entire icon will darken, and you'll see a dial spin around slowly lighting the icon back up. And here is how I did it. I used 2 squares. One square for the spell icon. And another that simply darkens it, only its rotated 45 degrees as a diamond. That dark square diamond is split into 8 polygons like a pizza, and its clipped around the regular square, so you can only see it within that square. I then shrink one polygon of the diamond pie one by one which coincides with realtime depending on what value you put for the cooldown amount until the time expires. Its accurate down to the very fraction of a millisecond through and through. If you want 10 minute cooldown, itll do it precisely. Or how bout 0.5 seconds. Not only did I do it using VB.Net, but also VB6. So here are both versions open source. Enjoy  :big yellow: 



*Note:* Niya claims that the VB.Net version of the spell cooldown had issues on his or her computer and not the VB6 one cause that one worked. I think its a she. But yet it works perfectly on mine. So if it looks like these pics in this link let me know: Possible Anomalies

----------


## Jacob Roman

I managed to simulate the error that Niya had so if you are in windowed mode and you maximize it, itll cause a black polygon to cover the spell icon. Reason why is because of Device.Reset(Screen). So over in your frmMain_Resize event, copy and paste this and it should fix the problem:


vb Code:
Private Sub frmMain_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize        If Fullscreen_Enabled = False Then            Running = False            Device.Reset(Screen)            Device.SetRenderState(RenderStates.AlphaBlendEnable, True)            'Needed for alphablending            '----------------------------------------------------------------------------------------------------            Device.SetTextureStageState(0, TextureStageStates.ColorOperation, TextureOperation.Modulate)            Device.SetTextureStageState(0, TextureStageStates.ColorArgument1, TextureArgument.TextureColor)            Device.SetTextureStageState(0, TextureStageStates.ColorArgument2, TextureArgument.Diffuse)             Device.SetTextureStageState(0, TextureStageStates.AlphaOperation, TextureOperation.Modulate)            Device.SetTextureStageState(0, TextureStageStates.AlphaArgument1, TextureArgument.TextureColor)            Device.SetTextureStageState(0, TextureStageStates.AlphaArgument2, TextureArgument.Diffuse)             Device.SetRenderState(RenderStates.SourceBlend, Blend.SourceAlpha)            Device.SetRenderState(RenderStates.DestinationBlend, Blend.InvSourceAlpha)            Device.SetRenderState(RenderStates.BlendOperation, TextureOperation.Add)            '----------------------------------------------------------------------------------------------------             'These lines are not needed, but it's nice to be able to filter the            'textures to make them look nicer.            Device.SetSamplerState(0, SamplerStageStates.MinFilter, TextureFilter.Point)            Device.SetSamplerState(0, SamplerStageStates.MagFilter, TextureFilter.Point)            Application.DoEvents()            Running = True        End If    End Sub

----------


## Niya

Sorry I took so long to get back to you on this. We had celebrations over here and I was offline gettin drunk for the weekend  :Wink: 

That code didn't fix the issue over here. It made in worst in fact. Now resizing doesn't fix the glitch.

Btw, I tried everything you suggested in the other thread and to no avail  :Frown: ....Except for running it on another PC. I will try that and see if the issue comes up and get back to you.

----------


## cuicui

I can't download WoW Cooldown VB6 file... why?

----------


## Jacob Roman

Hmmmm that is strange. I'll have to fix that if I can find the original code. The others download just fine at least.

[EDIT] Unfortunately I lost the code due to a corrupt harddrive from a few months ago. So what I'm gonna do is remake it in VB6, C#, and C++ with some improvements such as the "After effect" once the cooldown is over, which could literally be anything. Might even wrap it into a class for UI purposes in an RPG. I did it once before in Java for Android and it worked perfectly off of the phone and tablet. So gimme time  :Wink:

----------

