Discuss Scratch

46009361
Scratcher
1000+ posts

Cat sometimes starts at a random position instead of 0,0

This only works if you don't click in the middle of the project window and you reload the page immediately before. The Scratch Cat goes to a random position, not the centre. Project link: https://scratch.mit.edu/projects/501277553

I know that this is a bug and not a misunderstanding because the cat is going to 0,0 in this script (click “See inside” on the project page for proof):
when green flag clicked
go to x: (0) y: (0)

Last edited by 46009361 (April 7, 2021 01:36:27)


Inspired by coder2045—which, in turn, got inspired by Mr_PenguinAlex.
What's wrong with these blocks? There are zero mistakes because no round has started yet. Beware that some of the mistakes don't relate to the Scratch blocks below.
// No round has started yet.
Be the first to comment all of the mistakes on my profile correctly and you'll get a love! You can't comment any mistakes right now because there are none!
46009361
Scratcher
1000+ posts

Cat sometimes starts at a random position instead of 0,0

Bump.

Inspired by coder2045—which, in turn, got inspired by Mr_PenguinAlex.
What's wrong with these blocks? There are zero mistakes because no round has started yet. Beware that some of the mistakes don't relate to the Scratch blocks below.
// No round has started yet.
Be the first to comment all of the mistakes on my profile correctly and you'll get a love! You can't comment any mistakes right now because there are none!
10goto10
Scratcher
500+ posts

Cat sometimes starts at a random position instead of 0,0

I’m pretty sure that the value of the FPS variable in the very first frame will be zero for the move (150/FPS) block. So that means the sprite will move infinity steps toward the computer mouse.

Do you have an Animate a Name project that you'd like to have added to a studio? Please leave a comment in this studio.

46009361
Scratcher
1000+ posts

Cat sometimes starts at a random position instead of 0,0

10goto10 wrote:

I’m pretty sure that the value of the FPS variable in the very first frame will be zero for the move (150/FPS) block. So that means the sprite will move infinity steps toward the computer mouse.
But then it moves away from the computer mouse! Why don't I see the cat at 0,0 immediately before then?

Inspired by coder2045—which, in turn, got inspired by Mr_PenguinAlex.
What's wrong with these blocks? There are zero mistakes because no round has started yet. Beware that some of the mistakes don't relate to the Scratch blocks below.
// No round has started yet.
Be the first to comment all of the mistakes on my profile correctly and you'll get a love! You can't comment any mistakes right now because there are none!
10goto10
Scratcher
500+ posts

Cat sometimes starts at a random position instead of 0,0

I can't seem to reproduce the problem that you are seeing except that it makes sense that you can't see the cat initially start in the center (0,0). It would only be there for at the start of the first frame. I've tried it on my windows 10 computer with Chrome and Firefox and also on my iPad and the cat never moves away from the computer mouse. Sorry I could not be more help.

Do you have an Animate a Name project that you'd like to have added to a studio? Please leave a comment in this studio.

Maximouse
Scratcher
1000+ posts

Cat sometimes starts at a random position instead of 0,0

It seems to work as expected for me. When you start the project the cat moves further than expected because the timer is zero. It does start at (0, 0) but it moves away before Scratch draws it.


This is Maximouse's signature. Learn more about signatures.
46009361
Scratcher
1000+ posts

Cat sometimes starts at a random position instead of 0,0

It's supposed to start exactly in the centre and be drawn before being moved only slightly again!

Inspired by coder2045—which, in turn, got inspired by Mr_PenguinAlex.
What's wrong with these blocks? There are zero mistakes because no round has started yet. Beware that some of the mistakes don't relate to the Scratch blocks below.
// No round has started yet.
Be the first to comment all of the mistakes on my profile correctly and you'll get a love! You can't comment any mistakes right now because there are none!
10goto10
Scratcher
500+ posts

Cat sometimes starts at a random position instead of 0,0

okay, but the way the script is written, it has a goto 0,0 and then shortly followed (in the code) by a move statement. That happens in the first frame (the first 1/30 of a second). The first time the move statement is executed the fps variable is zero, so the amount of steps moved will be infinity (and this is still what happens in that first 1/30'th of a second). So, using a small wait block right after the goto 0,0 would probably help and setting FPS to 30 right at the start of that same script would also probably help.

I still don't understand why it would move away from the computer mouse.

Do you have an Animate a Name project that you'd like to have added to a studio? Please leave a comment in this studio.

46009361
Scratcher
1000+ posts

Cat sometimes starts at a random position instead of 0,0

10goto10 wrote:

okay, but the way the script is written, it has a goto 0,0 and then shortly followed (in the code) by a move statement. That happens in the first frame (the first 1/30 of a second). The first time the move statement is executed the fps variable is zero, so the amount of steps moved will be infinity (and this is still what happens in that first 1/30'th of a second). So, using a small wait block right after the goto 0,0 would probably help and setting FPS to 30 right at the start of that same script would also probably help.

I still don't understand why it would move away from the computer mouse.
That's because it isn't checking for the distance to the mouse-pointer.

Inspired by coder2045—which, in turn, got inspired by Mr_PenguinAlex.
What's wrong with these blocks? There are zero mistakes because no round has started yet. Beware that some of the mistakes don't relate to the Scratch blocks below.
// No round has started yet.
Be the first to comment all of the mistakes on my profile correctly and you'll get a love! You can't comment any mistakes right now because there are none!

Powered by DjangoBB