Discuss Scratch

1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

I've been working on a project for days, and have still been stuck, I read every discussion and saw every Youtube video, but I still need help. My task is to submit a Scratch program counting forwards and backward from 1 to any number selected by the user. I've Done 70% of the work but it's just the counting forwards and backward that I'm terribly stuck on. PLEASE HELP!!
1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

deck26
Scratcher
1000+ posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

That's just a basic loop. Set a variable to the starting value and repeatedly increase/decrease it by 1 until it reaches the target.

If you're counting from 1 to n you could just use a repeat (n - 1) loop. Use one loop to increase and another to decrease.
JamieHosier
Scratcher
29 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.


step 1: determine if your number is greater or less than N, and store that info in a new variable

if <(number) > [1]> then 
set [isgreaterthan1 v] to [1]
else
set [isgreaterthan1 v] to [0]
end

step 2: count from 1
if <(isgreaterthan1) = [1]> then 

repeat until <(count) = (number)>
change [count v] by (1)
wait (0.01) secs
end

else
repeat until <(count) = (number)>
change [count v] by (-1)
wait (0.01) secs
end
end

if theres something you want me to explain, tell me

Last edited by JamieHosier (Aug. 18, 2019 20:47:12)

1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

can you please show me how
1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

@JamieHosier: thank you soo much! I understood the 2 loops and I even put them into the project, but it still didn't work. I looked at it carefully but still could not find the problem. Here's the link- https://scratch.mit.edu/projects/324595765/editor
1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

So basically, the project is supposed to look like the cat saying the numbers forwards and backward from 1 to any number selected by the user.
-ShadowOfTheFuture-
Scratcher
1000+ posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

EDIT: I've looked at your post again, and now I'm a bit confused… do you want the cat to say the numbers from some number to 1 and back to that number, or just go from that number to 1?

1044747 wrote:

@JamieHosier: thank you soo much! I understood the 2 loops and I even put them into the project, but it still didn't work. I looked at it carefully but still could not find the problem. Here's the link- https://scratch.mit.edu/projects/324595765/editor
The project isn't shared - can you share it so we're able to view it?

Maybe you could try something like this? I'm not sure if it would work, but it might…

set [change v] to ((2) * (<(number) > [1]> - (0.5))) // sets "change" to 1 or -1 depending on if "number" > 1
repeat ([abs v] of ((number) - (1)))
say (number) for (1) secs
change [number v] by (change)
end
say [1] for (1) secs

Last edited by -ShadowOfTheFuture- (Aug. 19, 2019 00:25:47)

deck26
Scratcher
1000+ posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

You can't change the built-in answer variable so there's no point in a loop comparing 1 with answer.

Set number to 1, say number, repeat until number = answer. To count back down change number by -1, say number, repeat until number =1.
1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

@deck26: Thank you soo much, I figured it out! It was exactly what you said! Just quick question: How do you get better at Scratch?
JamieHosier
Scratcher
29 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

1044747 wrote:

@deck26: Thank you soo much, I figured it out! It was exactly what you said! Just quick question: How do you get better at Scratch?

you need experience. lots of it. i've been on scratch for over 3 years. when i started, i didnt know anything about it
1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

@JamieHosier: Oh wow, 3 years! I just started about 2 weeks ago for my AP Computer Science class. Are you all high school students as well?
1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

Do you guys have any advice for a beginner like me? Like what do I do when I'm stuck? Or what are some good resources for any help? or just anything you would like to give me a heads up on?
deck26
Scratcher
1000+ posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

1044747 wrote:

Do you guys have any advice for a beginner like me? Like what do I do when I'm stuck? Or what are some good resources for any help? or just anything you would like to give me a heads up on?
Look at what others have done, Scratch has the big advantage that you can always look inside projects. Some will be too complex for you but don't worry about that, just move on to something else. Get familiar with all the blocks and just try things. Perhaps try remixing projects and see if you can make changes to them.

Be patient, don't expect to understand it all at once. If something you try doesn't work and you can't work out why just come back here and post a new topic.

I've only been programming for 40 years or so! Scratch is quite different from what was available when I started though.

1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

@deck26: Thank you soo much for the helpful advice! But right now in the US, summer is still here, which assumingly is the reason why I've been receiving quick replies; will it remain like this later on the year, or in the next 10 days or so? Anyhow, I look forward to working with such a supportive and positive group!

Last edited by 1044747 (Aug. 19, 2019 21:40:40)

codeman1044
Scratcher
1000+ posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

1044747 wrote:

will it remain like this later on the year, or in the next 10 days or so?
Usually, as the school year starts fewer users are active on scratch. There are some that are always active, but not as many as over the summer. I personally try to be active on scratch each day, no matter if I'm in school or not, but I can't be certain about most other people.
I know some people that are active the most during the school year as well!
Maybe because I bug them to sometimes when I see them … nah, it can't be that.
In short: while the forums may not be as active, you will still see an active population here. Don't worry!
1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

.

Last edited by 1044747 (Aug. 21, 2019 00:21:12)

1044747
Scratcher
15 posts

Scratch program counting forwards and backwards from 1 to any number selected by the user.

this could not have been possible without you all!

Powered by DjangoBB