Discuss Scratch

-____-_-
Scratcher
16 posts

How do I make a timer out of sprites and variables.

I need help making a timer out of sprites.
MasterofTheBrick
Scratcher
1000+ posts

How do I make a timer out of sprites and variables.

To be more specific, you want a text engine that displays each number of the timer as a sprite costume?
-____-_-
Scratcher
16 posts

How do I make a timer out of sprites and variables.

MasterofTheBrick wrote:

To be more specific, you want a text engine that displays each number of the timer as a sprite costume?
I don't know how to use text editors but yes. (I want the a timer out of sprites so when u start it will be 25 mins then 2 mins later it will be 23 mins and the sprites will change costume depending on the timer.)
Can u help me?

Last edited by -____-_- (June 22, 2021 18:02:53)

-ShadowOfTheFuture-
Scratcher
1000+ posts

How do I make a timer out of sprites and variables.

-____-_- wrote:

MasterofTheBrick wrote:

To be more specific, you want a text engine that displays each number of the timer as a sprite costume?
I don't know how to use text editors but yes. (I want the a timer out of sprites so when u start it will be 25 mins then 2 mins later it will be 23 mins and the sprites will change costume depending on the timer.)
Can u help me?
In principle, a text engine goes through whichever word (or number) you want to print out, checks each letter or digit in order, then prints out that letter, either by using the pen extension or by stamping or cloning the costume corresponding to that letter.

Your text engine sprite, in this case, would have ten costumes, each corresponding to a digit from 0-9. When you want to print out a certain number, you would start at the first digit, switch to that costume, stamp or clone the sprite, then move forwards (so the digits don't overlap each other) and check the second digit, etc. until you've gone through and printed every digit in that number.

For the timer, you could make use of Scratch's built in timer block; whenever you want to set your timer to some number, you could reset the built in timer and set some other variable to your desired number minus that timer. You may also want to round the number down, as well, so the display looks a bit nicer, so you could end up having something like

when you want to start your timer,
reset timer
set (countdown v) to (floor of (your number - timer/60))


(assuming you want the counter to count minutes instead of seconds)

I made a simple mockup here: https://scratch.mit.edu/projects/547305792/. It counts down in seconds instead of minutes, but I think you can probably change it to count in minutes by dividing the built in timer by 60.

Last edited by -ShadowOfTheFuture- (June 22, 2021 21:27:00)

-____-_-
Scratcher
16 posts

How do I make a timer out of sprites and variables.

-ShadowOfTheFuture- wrote:

-____-_- wrote:

MasterofTheBrick wrote:

To be more specific, you want a text engine that displays each number of the timer as a sprite costume?
I don't know how to use text editors but yes. (I want the a timer out of sprites so when u start it will be 25 mins then 2 mins later it will be 23 mins and the sprites will change costume depending on the timer.)
Can u help me?
In principle, a text engine goes through whichever word (or number) you want to print out, checks each letter or digit in order, then prints out that letter, either by using the pen extension or by stamping or cloning the costume corresponding to that letter.

Your text engine sprite, in this case, would have ten costumes, each corresponding to a digit from 0-9. When you want to print out a certain number, you would start at the first digit, switch to that costume, stamp or clone the sprite, then move forwards (so the digits don't overlap each other) and check the second digit, etc. until you've gone through and printed every digit in that number.

For the timer, you could make use of Scratch's built in timer block; whenever you want to set your timer to some number, you could reset the built in timer and set some other variable to your desired number minus that timer. You may also want to round the number down, as well, so the display looks a bit nicer, so you could end up having something like

when you want to start your timer,
reset timer
set (countdown v) to (floor of (your number - timer/60))


(assuming you want the counter to count minutes instead of seconds)

I made a simple mockup here: https://scratch.mit.edu/projects/547305792/. It counts down in seconds instead of minutes, but I think you can probably change it to count in minutes by dividing the built in timer by 60.
I don't get how to change it to minutes
Oumuamua
Scratcher
1000+ posts

How do I make a timer out of sprites and variables.

https://scratch.mit.edu/projects/399220424/

That might help, it does a minutes countdown.
I am pretty sure you hopefully can to work on it and adapt to suit to that what you need

Last edited by Oumuamua (June 29, 2021 00:17:26)

MasterofTheBrick
Scratcher
1000+ posts

How do I make a timer out of sprites and variables.

The post already said to divide the timer by 60. 1 minute is 60 seconds, so the timer divided by 60 would give you the total number of minutes.

Last edited by MasterofTheBrick (June 29, 2021 00:18:39)

Powered by DjangoBB