Microsoft MakeCode

Get countdown value

Is there any way to get the remaining value of the countdown timer? I want to use that value to calculate a score based on how quick the player completed a task.

1 Like

You could turn the countdown timer into a variable. (ex. Countdown variable) and you could do a random number you chose. (ex. 100) and do this -> 100 - Countdown variable and put that into a set points to __ block I guess

2 Likes

I’m not sure if I understand yours, but what I was thinking was to just have a variable along side that containing the seconds that you started with and in an on game update every 1000 ms you would subtract the variable by one, simulating the countdown timer in memory. It wouldn’t be as accurate though, because I tried before in a separate game.

1 Like

That is what I’m explaining. or almost. Kinda what i was talking about but I think you’re thinking of the same thing as me except I forgot to put in the part of the 1000 ms

1 Like

Great minds think alike.

At least I hope they do.

I did that very thing in my sample Maze Game. (Link to thread here; scroll down to the Maze Game 2.0 Blocks game.) There isn’t a block that you can use to find the remaining time on the countdown clock, so I saved the current “game clock” to a variable when the countdown starts, and then I calculate the elapsed time at the end of the game.

3 Likes

By:

you mean the milliseconds since start?

I appreciate all of your ideas. I was thinking that the best option would be to save the value of ‘game time since start’ when the level starts, and then get it again when the level finishes, and subtract the two. I was just hoping there would be a ‘getter’ for the function, since you can set it.

Maybe you guys can help me out on a other issue. I will post something shortly about a game I developing.

3 Likes