We will build the functionality to update text info into a method that will update not only the time left, but also the game's score value.
1. Add a new method called
UpdateInfoText
in thegame
class.Method UpdateInfoText:Int()
2. Set the text property of
txtScore
with the score value.txtScore.SetText(score)
3. Calculate the number of seconds left by subtracting the current millisecond value from the end time, after adding
750
(to make it more accurate), and then dividing everything by1000
, to get seconds.seconds = (endTime-Millisecs()+750)/1000
4. Determine the number of minutes left using the value of
seconds
.minutes = seconds/60
5. Subtract the result of minutes times 60 to get the seconds left.
seconds -= (minutes*60)
6. Depending on how many seconds are left, set the text property of
txtTime
.If seconds > 9 Then txtTime.SetText(minutes+":"+seconds) Else txtTime.SetText(minutes+":0"+seconds) Endif
7. Close this method.
Return 0 End End