Discuss Scratch

VintageCupcake
Scratcher
3 posts

the "repeat until" block isn't working

I want my sprite to move right until the space key is pressed and then move up until the space key is pressed but it keeps going right even if I press the space key.
repeatuntilkey spacepressed?changexby10repeatuntilkey spacepressed?changeyby10
Am i doing something wrong?
GunChleoc
Scratcher
500+ posts

the "repeat until" block isn't working

It works if you define a different key in the second block. I'm new to Scratch, so don't ask my why you can't use the same key for both.
drmcw
Scratcher
1000+ posts

the "repeat until" block isn't working

When that script is running then the sprite will move right until the space key is pressed, once it is pressed then the script drops through to the next bit of script and runs that. The time that script takes to run would depend on your PC but would likely be measurable in nanoseconds. Even assuming the key pressed logic reads the keys each time you request it then do you think you'd be able to lift the key within a nanonsecond timescale? IN other words for the next loop the key pressed will always be true so it will never go upwards. If you want to have the space key released after the first repeat then add
waituntilnotkeyspacepressed?
3sal2
Scratcher
100+ posts

the "repeat until" block isn't working

Because you have a copy of the first repeat until block beneath the first one.
Seapats
Scratcher
70 posts

the "repeat until" block isn't working

beacause you have the same operator!
Try:
repeatuntilkeyspacepressed?changexby10waituntilnotkeyspacepressed?repeatuntilkeyspacepressed?changeyby10
VintageCupcake
Scratcher
3 posts

the "repeat until" block isn't working

Thanks so much.
Truebuild
New Scratcher
3 posts

the "repeat until" block isn't working

Seapats wrote:

beacause you have the same operator!
Try:
repeatuntilkeyspacepressed?changexby10waituntilnotkeyspacepressed?repeatuntilkeyspacepressed?changeyby10
This example shows a not operator with round ends inside a wait until control!
in my scratch (I presume scratch 2) the wait until control has diamond shaped ends and the key press sensing code is diamond sharp ended (not rounded)
Why is that?

I am looking at this code because I want to implement this example but in my case using “J” instead of space key
when space key pressed this is ok
set pressingspace to 1 this is ok because I have created a variable “pressingJ”
wait until pressingspace<0 this is the problem because pressingJ is a long oval and does not fit the square box < box 0 in wait until
wait until not key space pressed this is the problem because pressingJ is a long oval and does not fit the long diamond socket in wait until
set pressingspace to 0 this is ok

Help please

Last edited by Truebuild (Feb. 8, 2016 21:31:15)

smiley_cat_rulez
Scratcher
100+ posts

the "repeat until" block isn't working

repeatuntilkeyjpressed?changexby10changeyby10

Last edited by smiley_cat_rulez (Feb. 9, 2016 02:40:42)

Powered by DjangoBB