My big question: is there a way to "reset" this timer when the time reaches 50 seconds? In game I'd like it to work this way:
-> counter is counting seconds to 50
-> if player didn't win the game in 50 seconds he loses one of his 3 lifes and plays again
-> when the player loses life the counter resets to zero so the player has another 50 seconds
-> if the player won the game and wants to play again timer is set to 0 seconds too
I couldn't figure out how to make this work... Thanks for ideas!
Thank you for help @Ganado, that works!
I have a question though, I put startTime variable at the beginning of my startFrogger() function, just after {. And, the value of startTime is very small and not constant - something around 0,1-0,2 seconds. Should it work this way?
And one more question, when the player loses game before the counter reaches 50 seconds, and wants to play again - how reset the timer?
This is how it looks now in my code:
gameOver function subtracks one life from player and then checks if player still have lifes > 0 to play. If player lost all his lifes and wants to play again, then inside gameOver function is called startFrogger() function which handles the game again... I find myself a little lost in how to reset this time in this situation :/