Adding 00:00 time with two values

code
questions
answered
counter
timer

#1

So I’m working an a random survival game called Tomato Head Survival… where your character has a tomato as a head so I don’t spend half the time staring at that smile… …anyways I’m adding a time measure (‘cause why not?) and one thing that would make sense if it wouldn’t be like 6 : 30 and more like 06:30. Any suggestions on how to make it?


#2

For a timer counting up I’d just use bumps.



This project has an object, which creates two clones. The original object then goes to the center of wherever you want the Tim to be, and becomes the :. The clones also go to the same place, and the first becomes the minutes counter while the second clone becomes the seconds counter.


The code to put the clones in their correct place is simple.


This rule only ever happens for clones, since the original object can’t bump itself.
It checks if it is the first clone created, and if it is, moves left. It repeats this until it is no longer touching the colon.
If it isn’t the first clone created, it moves right until it isn’t touching the colon.




Hope this helps.


#3

There’s a couple different ways to add the leading 0s so, for example the timer might read 01:09 instead of 1 : 9

This method needs a little more code, but is simpler. First, use an object to continually count seconds


(Note: using 966.7 verses 1000 increases the accuracy to account for the time to execute the Increase block)

Then use 3 objects to display the minutes, seconds, and “:” between the numbers. Set up the relative positions however you’d like.

The leading 0s can be displayed using nested conditionals & a little math. The object displaying seconds would use code like this:

continuing on to the final Else that catches anything over 09

The Time%60 uses modulo to convert the total elapsed number of seconds to just the number of seconds left after considering minutes too.

The object displaying minutes would have similar nested conditionals, but the math would be this instead:


That formula is just dividing by 60 to figure out how many minutes have passed, and keeping only the whole number part of the answer.


#4

Thank you @ThinBuffalo and @Petrichor for answering this question. I had this question too and you really answered it good. I will boookmark your posts for future reference.