Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate and match Scratch's timer implementation #180

Open
towerofnix opened this issue Mar 18, 2023 · 2 comments
Open

Investigate and match Scratch's timer implementation #180

towerofnix opened this issue Mar 18, 2023 · 2 comments
Labels
compatibility Bugs that cause Leopard's behavior to differ from Scratch's

Comments

@towerofnix
Copy link
Member

The current timer implementation in Leopard is very rudimentary:

leopard/src/Project.js

Lines 251 to 254 in 25652b1

get timer() {
const ms = new Date() - this.timerStart;
return ms / 1000;
}

This would be quite dandy if that's how the timer worked in Scratch, too, but it's not 📦

See this project I made last year which shows that the timer block is only updated once every rendered Scratch frame. (The main project loop runs many times in one frame unless you click "simulate movement", which enables requesting a screen redraw every tick.)

See all the gruesome details in scratch-vm: clock.js, sequencer.js.

@towerofnix towerofnix added the compatibility Bugs that cause Leopard's behavior to differ from Scratch's label Mar 18, 2023
@another-m00
Copy link

Related Timer implementation is Scratch-vm

@another-m00
Copy link

It appears that the timer itself was implemented pretty similarly, except they used this date method as fallback for the performance counter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Bugs that cause Leopard's behavior to differ from Scratch's
Projects
None yet
Development

No branches or pull requests

2 participants