This site requires JavaScript, please enable it in your browser!
Greenfoot back
DamonAG
DamonAG wrote ...

2017/4/20

Timer and Lap Counter

DamonAG DamonAG

2017/4/20

#
Hello everyone! I am creating a 'race against the clock' game with a race track and a car. Does anyone know how to add a 3Lap display (1/3, 2/3, 3/3, Finish) for when my car crosses the starting point again? I was also wondering if anyone knows how to make a 60-120 second timer (displayed alongside the 3Lap display) that once it reaches 0 would send me to the loss screen. I would like this timer to still be active when I change worlds so that if I add questions for a review type game, it would still be race against the clock to answer the questions correctly (answering them incorrectly does not fail the game). All I need is the timer and lap counter.
danpost danpost

2017/4/20

#
My Value Display Tutorial scenario shows how to create both those objects. The only thing about your problem that is not covered in it is how to detect the laps. To do that will require a check between two consecutive states so that the change in state can be detected. Otherwise, the state could remain in effect for multiple act methods and you do not want to log in laps that were not made. Not knowing exactly what you are dealing with, any given code would require checks for direction across the finish line as well -- maybe subtracting a lap made if crossing the line while going in the reverse direction around the track. Anyway, these are things to be considered.
You need to login to post a reply.