count down timer not working in Win7

Everything AM users with W7 computers need to know

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

count down timer not working in Win7

Postby reneuend » Tue Dec 21, 2010 4:22 am

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
     Else
        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
         RemoveTimedEvent(0)
         Text(4).Caption = "0"
         Action.GoToFrame("score")
         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



---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2684
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby juhuwoorps » Tue Dec 21, 2010 7:57 am

What doesn't work? The whole counter? Where do you set the timedevent?

Edit:

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

Variables:
Code: Select all
counter


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


VBS Procedure:

Code: Select all
sub countered
counter=counter-1
Text(1).alignment=2
Text(1)=counter
If counter < 10 Then
Text(1).ForeColor = RGB(255,0,0)
sound "beep-7.mp3"
End If
If counter=0 then
sound"fail-buzzer-04.mp3"
Action.GoToFrame("Solid02")
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"
Else
   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
   Component("MediaPlayer1").Object.Play
End If
End Sub



You can find a demo and the project folder on my website :)
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby reneuend » Tue Dec 21, 2010 2:27 pm

You're awesome! Thanks Juhu! :)
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2684
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA


Return to Windows 7 issues

Who is online

Users browsing this forum: No registered users and 0 guests

cron