Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Can you reset Gosu.milliseconds back to zero?
- - By OldBoy Date 2016-07-20 17:27
I made a simple card-memory game, and I want to implement timer/stopwatch (to record fastest time).
Gosu.milliseconds works for the first playthrough, but then just keeps counting.
Can I reset Gosu.milliseconds back to zero or should I use ruby time class (or something else)?
Parent - - By lol_o2 Date 2016-07-20 17:48
Just save milliseconds to a variable at the beginning of round and then (milliseconds - variable) will be your stopwatch.
Parent - - By OldBoy Date 2016-07-21 16:29
it's not that easy, there is an unknown time gap between when the game ends, and when the player click on "play again" button. looks like I'll have to implement custom Stopwatch class (or add 5 extra variables ...). It would be much easier if I could just restart Gosu::milliseconds :/
Parent - By lol_o2 Date 2016-07-21 17:57
Er, what?

if player_started
  @start_time = milliseconds
end

if round_finished
  @round_time = milliseconds - @start_time
end


That's the rough code. You need only 1 variable.
Up Topic Gosu / Gosu Exchange / Can you reset Gosu.milliseconds back to zero?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill