Creating a Timer or Score Keeping function in the games

Does anyone know how to create a timer or score keeping function in the sprite lab, app lab or game lab? We have been looking around and don’t seem to find the answer.

Hi @geri_hamada,

There are a few different ways to use a timer - and countless ways to “keep a score”. If you have a specific problem you are working on, perhaps I can help point you in the right direction, but if you just need more info, I suggest checking out this post: How to design and code a Timer in AppLab?

That should give you some ideas! In particular, I always like the examples!
KT

Okay . . .thanks for the information . . . but now my students are asking for help in sprite lab to make a timer or keep score. Is that possible?

I was not able to find any documentation to create a timer in Sprite Lab. But, you can do it in AppLab and GameLab. Here is a post on the forum that explains how to make a timer in GameLab. @Katie has already shared a link for AppLab.

Too bad!! My students are working with the sprite lab and were hoping to get some help. They have also tried looking on the internet and there seems to be nothing.

Well, if you think of something . . . any suggestion would be appreciated!

I’m not familiar with all the mechanics of sprite lab, but you can apply the basic principles of score keeping from the Game Lab lessons in CS Discoveries.

Here’s an example I made: https://studio.code.org/projects/spritelab/1_87sl9JGaSOZFf0p9rDLCejzyS-YfnUgjrhFhDCSRA

Click the sprite to increase the score.

I wasn’t sure how to display the numbers, so all I could find was a “title” block. It also seems to register a click as continuously repeating clicks, so not the behavior I was going for. Nonetheless, there’s the skeleton of a scorekeeping algorithm which is to initiate a variable with a value of 0, then on some event, increase the value of that variable by some number.

As for timing, there does not appear to be any functions specifically for timing. The only possible chance might be to do something hack-y like have something loop thousands of times in order to create a pause or use some other action that takes a finite amount of time (like a sprite movement maybe).

Hi @kaitie_o_bryan
Are you able to point me at the most simple of simple tutorials for creating a score on applab?

@richard.knuckey,

Here’s a quick and easy tutorial on keeping score in a simple counter game from the CSP curriculum.

https://studio.code.org/s/csp5-2019/stage/5/puzzle/1

Mike

Thanks again Mike. But that link just points to the sign in page (?)

@richard.knuckey, you may have to sign in to access it as it is part of the CSP course, however I edited my original post so the entire URL is there … (may not be clickable, but you should be able to copy and paste). And here it is again …

https://studio.code.org/s/csp5-2019/stage/5/puzzle/1 

thanks,

Mike

1 Like

Hi again…
I’ve got a student wanting a button to fade in onto the home screen on a applab project. The button will then activate the second screen. I suspect it’s something to do with the Set Timeout control…
Any help appreciated! Here is the project

1 Like

For Sprite Labe, it’s actually quite simple. You will want to make a sprite with a behavior, you build yourself.

Timer - Sprite Lab - Code.org

Screen Shot 2022-12-09 at 7.22.35 PM

I couldn’t find an answer to this. But here is how to build a timer in Sprite Lab. Just add some logic to be processed on each completion and then add the “reset timer” block (found in the World category) at the end.