Discuss Scratch

Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

i have been making an simon says remake for my school project, (i will post the full thing soon. the version used is just for the school project) and i am using an system to imitate the animations they use in arcades using a timer, but if i use these stop buttons, that messes up! so is there a way to make a stop button without a timer?
meercat213
Scratcher
57 posts

Stop Pressed button w/o timer

Luigi_Lemos wrote:

i have been making an simon says remake for my school project, (i will post the full thing soon. the version used is just for the school project) and i am using an system to imitate the animations they use in arcades using a timer, but if i use these stop buttons, that messes up! so is there a way to make a stop button without a timer?

Do you need it just for a Thumbnail or for an animation?

If you just need it for a Thumbnail you can do it like this:

when green flag clicked
set [ghost v] effect to (100)
forever
go to [front v] layer
end
Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

oh sweet thx







i hate creepy emojis removing emoticons >:[

Last edited by Luigi_Lemos (Oct. 15, 2025 23:17:21)

Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

now altough this isnt the topic for this, i wanna know how to detect if your mouse is moving or not, as i want a system that starts another game when your mouse is moving during the “arcade animation” (custom block)

if you do need it to help make the code, here is the code, {my animation has 156 frames ;-;}


define arcade animation
repeat until <[undefined code] = [right now]>
switch costume to [frame1 v]
repeat (156)
wait (0.1) secs
next costume
end
end

if you have a system that does not use variables, i would appreciate it!
N8_D_GR8_1
Scratcher
1000+ posts

Stop Pressed button w/o timer

Luigi_Lemos wrote:

now altough this isnt the topic for this, i wanna know how to detect if your mouse is moving or not, as i want a system that starts another game when your mouse is moving during the “arcade animation” (custom block)

if you do need it to help make the code, here is the code, {my animation has 156 frames ;-;}


define arcade animation
repeat until <[undefined code] = [right now]>
switch costume to [frame1 v]
repeat (156)
wait (0.1) secs
next costume
end
end

if you have a system that does not use variables, i would appreciate it!
In the future, you should create a new topic for a separate question. If you post it on the page, someone might see that your original question was already answered and assume that you don't need help anymore.

To detect when your mouse moves, you can store the mouse's previous position in variables. Then, if the current position is different from the previous position, you know that the mouse has moved. Here's what that looks like in code:

when I receive [wait for mouse movement v]
set [previous mouse x v] to (mouse x)
set [previous mouse y v] to (mouse y)
repeat until <not <<(mouse x)=(previous mouse x)>and<(mouse y)=(previous mouse y)>>>
set [previous mouse x v] to (mouse x)
set [previous mouse y v] to (mouse y)
end
broadcast (mouse moved! v)
Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

oh ok, but i did say on the bottom if there is a way w/o variables,
N8_D_GR8_1
Scratcher
1000+ posts

Stop Pressed button w/o timer

Luigi_Lemos wrote:

oh ok, but i did say on the bottom if there is a way w/o variables,
Oh, sorry I didn't see that. Is there a reason why?
Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

N8_D_GR8_1 wrote:

Luigi_Lemos wrote:

oh ok, but i did say on the bottom if there is a way w/o variables,
Oh, sorry I didn't see that. Is there a reason why?
well its because there is only 1 day left to make the project, and cause im kinda tired

here is the code to help

when green flag clicked
wait until <[(timer)] > [15]>
if <[(timer)] > [15]> then
set [arcade animation v] to [1]
end
that code isnt exact, but that one is for the animation, now for the other.

when green flag clicked
if <unknown code> then
reset timer

end
N8_D_GR8_1
Scratcher
1000+ posts

Stop Pressed button w/o timer

Luigi_Lemos wrote:

well its because there is only 1 day left to make the project, and cause im kinda tired
This is an example of the XY problem. Doing it without variables will end up leading to a more complex solution. Using variables is simply the easiest way (at least in my opinion).

Luigi_Lemos wrote:

here is the code to help

when green flag clicked
wait until <(timer) > [15]>
if <(timer) > [15]> then
set [arcade animation v] to [1]
end
that code isnt exact, but that one is for the animation, now for the other.

when green flag clicked
if <unknown code::grey> then
reset timer
end
(modified for clarity)
Thanks for providing the code. That provides good insight into the context of what you are doing. You can replace the second script with this:

when gf clicked
set [previous mouse x v] to (mouse x)
set [previous mouse y v] to (mouse y)
forever
repeat until <not <<(mouse x)=(previous mouse x)>and<(mouse y)=(previous mouse y)>>>
set [previous mouse x v] to (mouse x)
set [previous mouse y v] to (mouse y)
end
reset timer
end
Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

hmmm, i think the code is broken, cause maybe its the forever, but after the timer is reset, its not coming back again.

Last edited by Luigi_Lemos (Oct. 17, 2025 14:28:13)

N8_D_GR8_1
Scratcher
1000+ posts

Stop Pressed button w/o timer

Luigi_Lemos wrote:

hmmm, i think the code is broken, cause maybe its the forever, but after the timer is reset, its not coming back again.
You are right. Here's a better version of my code:
when gf clicked
forever
if <not <<(mouse x)=(previous mouse x)>and<(mouse y)=(previous mouse y)>>> then
reset timer
end
set [previous mouse x v] to (mouse x)
set [previous mouse y v] to (mouse y)
end

I tested this out and it works as expected.

Last edited by N8_D_GR8_1 (Oct. 17, 2025 17:22:09)

Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

sweet! last thing i need to know is how to stop the arcade anim.
N8_D_GR8_1
Scratcher
1000+ posts

Stop Pressed button w/o timer

Luigi_Lemos wrote:

sweet! last thing i need to know is how to stop the arcade anim.
This block will come in handy for that:
stop [other scripts in sprite v]

..as long as there are no other scripts that you want to not stop.
Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

its only 1 sprite ;-; (if u dont count the thumbnail) so, H E L L N O
N8_D_GR8_1
Scratcher
1000+ posts

Stop Pressed button w/o timer

Luigi_Lemos wrote:

its only 1 sprite ;-; (if u dont count the thumbnail) so, H E L L N O
When do you want the animation to stop? When the mouse is moved?
Luigi_Lemos
Scratcher
9 posts

Stop Pressed button w/o timer

yep. actually, im doing a online lesson with my programming teacher rn, so i will get back when the lesson is done, (if the code is still unfinished)

Powered by DjangoBB