Discuss Scratch

Castiel3
New to Scratch
4 posts

Different Movement Speeds When Flag is Pressed

Hi, I was wondering if anyone could help me with a script that moves a sprite on the x axis different speeds each time the flag is pressed. Currently I have a script that says that when flag is pressed change x position; pick random between 1 and 10, but it seems to be constantly switching between 1 and 10 forever. I tried using a repeat until, a repeat once, a forever, and a combination between them. Any help would be greatly apprieciated, thanks.

Last edited by Castiel3 (Nov. 23, 2017 21:11:06)

MonzaM0nk3y123
Scratcher
43 posts

Different Movement Speeds When Flag is Pressed

could you share the project so that I can see what I can do?
Castiel3
New to Scratch
4 posts

Different Movement Speeds When Flag is Pressed

I have the offline version how do i share it?
Castiel3
New to Scratch
4 posts

Different Movement Speeds When Flag is Pressed

Castiel3
New to Scratch
4 posts

Different Movement Speeds When Flag is Pressed

^^^^^

MonzaM0nk3y123 wrote:

could you share the project so that I can see what I can do?
deck26
Scratcher
1000+ posts

Different Movement Speeds When Flag is Pressed

If you want the speed to be random each time you click the flag but be constant for that sprite within that run of the code you'll need a variable.

set [speed v] to (pick random (1) to (10))
repeat until <> // I'll leave you to sort out the stopping condition
move (speed) steps
end
You'll probably want a short delay in the loop as well.

Powered by DjangoBB