Page 1 of 1

count down timer not working in Win7

PostPosted: Tue Dec 21, 2010 4:22 am
by reneuend
I'm currently rebuilding Texas Shoot 'Em to Windows 7 compatibiltiy, but found that the countdown timer doesn't work. Does anyone have a solution for a countdown timer that will work with Windows 7?

The current timer code is from ShadowHunter I believe (shown below).

The good news is: This game uses the new Keyguard features very heavily and it's working flawlessly!

Thanks for any help

Code: Select all

Sub TimerStart(gTimer)
   gTimer = Timer
End Sub

Function TimerElapsed(beginTime)
     If beginTime <> 0 Then
   TimerElapsed = Timer - beginTime
        TimerElapsed = 0
     End If
End Function

Sub TimerReset(gTimer)
   gTimer = 0
End Sub

Sub UpdateCounter()
'This routine deals with the count down timer. It also changes the font color when the time is <20 and <10
'when the counter changes from 2 digit to one digit the position is adjusted to keep it centered. When the
'counter is <10 a new control is loaded to show in big red font the time in the center of the map
'When the time is up the timed event is removed and the game over screen is displayed.
   If CountDownTimer = 1 Then
         Text(4).Caption = "0"
         Exit Sub
       End If
       CountDownTimer  =  CountDownTimer - 1
   If CountDownTimer = 10 Then
     PlaySound2 GetPath(4) & "red_tail_hawk.mp3", 3, False
       End If

       If CountDownTimer < 10 Then
         Text(4).ForeColor = RGB(255,0,0)
   End If

   Text(4).Caption = CountDownTimer

End Sub

PostPosted: Tue Dec 21, 2010 7:57 am
by juhuwoorps
What doesn't work? The whole counter? Where do you set the timedevent?


I have tried this code for a simple counter and it works with WIN7:

Code: Select all

Frame properties:
Code: Select all
ctimer=Action.CreateTimedEvent (1,"countered",true)

VBS Procedure:

Code: Select all
sub countered
If counter < 10 Then
Text(1).ForeColor = RGB(255,0,0)
sound "beep-7.mp3"
End If
If counter=0 then
RemoveTimedEvent (ctimer)
End If
End Sub
SUB sound (soundfile)
If Action.IsComponentInstalled("NSPlay.NSPlayCtl.1") = False Then
    MsgBox "Unable to find the media player component.", vbCritical, "Error"
   If Action.DoesComponentExist("MediaPlayer1") = false Then
      AddComponent "NSPlay.NSPlayCtl.1", "MediaPlayer1"
   End If
   Component("MediaPlayer1").Object.FileName = GetPath(2)&soundfile '(replace with your file)
   Component("MediaPlayer1").Object.PlayCount = 1
End If
End Sub

You can find a demo and the project folder on my website :)

PostPosted: Tue Dec 21, 2010 2:27 pm
by reneuend
You're awesome! Thanks Juhu! :)