Discuss Scratch

GalloperRanch
New Scratcher
2 posts

Help with Understanding Scratch

Howdy!

So, I did DGT (Digital Technology) this year, and failed Scratch. I just did not understand the codes and stuff at all.

We ended on having the permission (well we had to) to make our own game. At that point, I couldn't even start it apart from adding and editing sprites.

Next year I am doing DGT for the whole year, (I did DGT for half the year) and I am panicking because I just do not understand Scratch (All the other subjects wouldn't do me good either). The main things I do not understand are:

1. Meanings of every code
2. Combinations (What they mean)


Sprites I am fine with, but I just don't get mainly those two things.
Can someone please help? Thank you!
MathPuppy314
Scratcher
500+ posts

Help with Understanding Scratch

This will tell you the basics for coding. There is a scratch wiki with tons of code for all subjects on it. You can also learn from there.
For a game with a player that can move:


At the beginning of any code you will need the
whenclicked
block. It just tells the code to start running.

movement wrote:

The movement blocks are dark blue. The
move#steps
block tells current sprite to move a # of steps in it's current direction
directionpointindirection#pointtowardsspriteturn#degreesturn#degrees
Turn blocks are pretty self explanatory.

There are also go to blocks and glide to blocks
gotox:#y:#gotospriteglide#secstox:#y:#glide#secstosprite not in forum scratch blocks

This will tell a sprite to instantly go to or gradually glide to any coordinate on the screen. For games, I mainly use that to start the program in a good spot.

The last movement blocks are
changexby# left(negative) or right(positive)changeyby# up(positive) or down(negative)andthesetxandyblocks I never use these

These are basically like the move (#) steps block but they change the x or y coordinate.

Next, since it is a game, we need user input. We do this using the light blue sensing blocks and the light brown control blocks.

sensing and control wrote:

–Control–

In control, you have repeat blocks.
foreverrepeat#repeatuntilcondition I will talk about the condition blocks soon.
whatever blocks you put inside repeat the specified amount

You also have if then blocks
ifconditionthenifconditionthenelse
Whatever is inside will only run if the condition is true. *Note that this block does not wait until your condition is true. It tests if it is true then either runs or doesn't. There are wait blocks. ↓

Wait blocks
wait#secswaituntilcondition
these will literally wait until the condition is met or the time runs down.


–Sensing–

You might be able to understand a lot of these. They are the condition blocks that we talked about earlier.
Some self explanatory ones are
touchingsprite?touchingcolor? you can esily choose the color from the stagecoloristouching?keyletters, numbers, arrowspressed? KEY PART IN ANY GAME!mousedown?
they will output true or false depending on what is happening.

You won't use the other ones very much at all.


Let's make a small car game!

1. Draw your car costume in a sprite.
2. Make a racetrack on the background (or a new sprite)
3. Make a script like this for the car
whenclicked starts programforeverifkeyup arrowpressed?thenmove10steps go forward if the up arrow is pressedifkeyright arrowpressed?thenturn15degrees turn if the right arrow is pressedifkeyleft arrowpressed?thenturn15degrees turn if the left arrow is pressedifkeydown arrowpressed?thenmove-7stepsnotice how the number here is negative - that goes backward go backward if the down arrow is pressed program will run without end

Last edited by MathPuppy314 (Dec. 22, 2019 15:41:50)

gor-dee
Scratcher
1000+ posts

Help with Understanding Scratch

As well as the wiki there are loads of tutorials written by other Scratchers. I made a database project here https://scratch.mit.edu/projects/73015636/ that may help you find some useful ones. I particularly liked the ones by @Your_Helpful_Teacher who has a studio here https://scratch.mit.edu/studios/1227030/
deck26
Scratcher
1000+ posts

Help with Understanding Scratch

Start with something simple. Get a sprite to go to the centre of the screen when you click the green flag and then say something or move. Then get it to move in a loop (move 5 steps) with a delay so it takes time to move across the screen. Play with the direction of movement and the rotation style.

DO NOT try to understand it all at once, take easy steps to start with. The movement and looks blocks are probably the ones to start with.

Is there anyone who can help you even if they're having to learn as they go? Parent/guardian/sibling/friend?
technoguyx
Scratcher
500+ posts

Help with Understanding Scratch

Scratch is a bit like mathematics. In maths, it's not enough if you understand each number and symbol in isolation, since the constructions you can make with those are just as important. For instance the number “3” could represent a ton of things, such as three apples, the three sides of a triangle, and even more abstract things such as a rectangle of area 3 or the remainder of dividing a number by another. The number “3” is like a small piece of a language that springs up in all of those contexts: arithmetic, algebra, geometry, etc.



Mathematics is a language to express ideas in a precise manner. Scratch is also a language to express ideas: in particular, it's a programming language, meaning that it's a language that is understood not only by humans, but by computers. You can give a computer precise instructions written in this language and it'll do exactly what you expect.

The trade-off is that, as you've experienced, it's not always obvious how to write what you want in this language. You need to think like the computer: a computer follows instructions in a sequential, i.e. step by step manner, and each of these steps must be one of the instructions that the computer recognizes. For instance, if we want to draw a square using the pen blocks, it can help to think of the precise steps one would do to draw a square on paper:

How to draw a square (English)
  1. Grab a pen and a blank piece of paper.
  2. Put the pen down on the paper at a certain spot.
  3. While holding the pen down, move it 3 cm up.
  4. Move the pen 3 cm to the right.
  5. Move the pen 3 cm down.
  6. Move the pen 3 cm to the left.
  7. Lift the pen from the paper.
Of course it seems very tedious if we write down every and each step like this, but the idea is very simple. In fact, this sort of list is more or less what you'd see in a Scratch script that draws a square, such as the following:

How to draw a square (Scratch)

whenclicked This means the script will start right when our project starts.clear This cleans up any pen drawings from the Stage, so we can start anew.gotox:0y:0 Go to a specific location in the Stage.pendown Put the pen down -- from now on, we're drawing.changeyby30 Move 30 steps (pixels) up.changexby30 Move 30 steps to the right.changeyby-30 Move 30 steps down. Note the negative number.changexby-30 Move 30 steps to the left.penup Lift the pen -- from now on this sprite won't be drawing on the Stage.

I hope this analogy has been helpful. As people have already suggested, take it easy and slow and if you need any further help you can ask on this forum, or search the Scratch Wiki which has a ton of useful articles and tutorials.

Last edited by technoguyx (Dec. 22, 2019 20:34:31)

GalloperRanch
New Scratcher
2 posts

Help with Understanding Scratch

technoguyx wrote:

“Scratch is a bit like mathematics. In maths, it's not enough if you understand each number and symbol in isolation, since the constructions you can make with those are just as important.”

How to draw a square (English)
  1. Grab a pen and a blank piece of paper.
  2. Put the pen down on the paper at a certain spot.
  3. While holding the pen down, move it 3 cm up.
  4. Move the pen 3 cm to the right.
  5. Move the pen 3 cm down.
  6. Move the pen 3 cm to the left.
  7. Lift the pen from the paper.
Of course it seems very tedious if we write down every and each step like this, but the idea is very simple. In fact, this sort of list is more or less what you'd see in a Scratch script that draws a square, such as the following:

How to draw a square (Scratch)

whenclicked This means the script will start right when our project starts.clear This cleans up any pen drawings from the Stage, so we can start anew.gotox:0y:0 Go to a specific location in the Stage.pendown Put the pen down -- from now on, we're drawing.changeyby30 Move 30 steps (pixels) up.changexby30 Move 30 steps to the right.changeyby-30 Move 30 steps down. Note the negative number.changexby-30 Move 30 steps to the left.penup Lift the pen -- from now on this sprite won't be drawing on the Stage.

I hope this analogy has been helpful. As people have already suggested, take it easy and slow and if you need any further help you can ask on this forum, or search the Scratch Wiki which has a ton of useful articles and tutorials.

No wonder! I do not know Maths AT ALL! I don't even know how to add two sprites on the same thing at the time. I am afraid I can't learn it before school starts again.
sushi_slamer
Scratcher
100+ posts

Help with Understanding Scratch

GalloperRanch wrote:

technoguyx wrote:

“Scratch is a bit like mathematics. In maths, it's not enough if you understand each number and symbol in isolation, since the constructions you can make with those are just as important.”

How to draw a square (English)
  1. Grab a pen and a blank piece of paper.
  2. Put the pen down on the paper at a certain spot.
  3. While holding the pen down, move it 3 cm up.
  4. Move the pen 3 cm to the right.
  5. Move the pen 3 cm down.
  6. Move the pen 3 cm to the left.
  7. Lift the pen from the paper.
Of course it seems very tedious if we write down every and each step like this, but the idea is very simple. In fact, this sort of list is more or less what you'd see in a Scratch script that draws a square, such as the following:

How to draw a square (Scratch)

whenclicked This means the script will start right when our project starts.clear This cleans up any pen drawings from the Stage, so we can start anew.gotox:0y:0 Go to a specific location in the Stage.pendown Put the pen down -- from now on, we're drawing.changeyby30 Move 30 steps (pixels) up.changexby30 Move 30 steps to the right.changeyby-30 Move 30 steps down. Note the negative number.changexby-30 Move 30 steps to the left.penup Lift the pen -- from now on this sprite won't be drawing on the Stage.

I hope this analogy has been helpful. As people have already suggested, take it easy and slow and if you need any further help you can ask on this forum, or search the Scratch Wiki which has a ton of useful articles and tutorials.

No wonder! I do not know Maths AT ALL! I don't even know how to add two sprites on the same thing at the time. I am afraid I can't learn it before school starts again.
The math is kinda a weird interpretation, but I see your point. Scratch can be difficult in the beginning but it will get easier as you go along.
dimitrip
Scratcher
500+ posts

Help with Understanding Scratch

Hi,

Hmm..
What browser do you use on which operating system, GalloperRanch?
Maybe a shared web session of a few minutes with a volunteer is enough to restore your confidence and get you on track.

Season Greetz,

Dimitri
marcelzietek2006
Scratcher
500+ posts

Help with Understanding Scratch

yeh i could help
(removed by moderator - please don't suggest using external chat sites)

Last edited by Paddle2See (Jan. 1, 2020 21:39:25)

Aldensgeomotrytwin
Scratcher
1 post

Help with Understanding Scratch

whenIreceive homeworksayscream
MrBeans1307
Scratcher
7 posts

Help with Understanding Scratch

whenthisspriteclickedsayhello there!for2secs

Last edited by MrBeans1307 (June 4, 2024 20:57:43)

OsomKoolGuy
Scratcher
78 posts

Help with Understanding Scratch

I recommend using some of your free time looking inside projects you like and seeing what blocks do in your own projects. Sometimes, though, projects can be difficult to understand. Many people like making recreations of really simple games like flappy bird or a maze first. One of my first ever projects (also for a school assignment) was a maze. I would recommend just using the first few categories of blocks, and not worry about variables, custom blocks, or pen yet. Just messing around can get you pretty far.
MrBeans1307
Scratcher
7 posts

Help with Understanding Scratch

How to make players move smoothly If needed!
whenclickedforeverchangexbykeydpressed?-keyapressed?*5changeybykeywpressed?-keyspressed?*5
It can be better with variables but that is Harder than this

Last edited by MrBeans1307 (June 4, 2024 21:18:21)

MrBeans1307
Scratcher
7 posts

Help with Understanding Scratch

Aldensgeomotrytwin wrote:

whenIreceive homeworksayscream
This is me
MrBeans1307
Scratcher
7 posts

Help with Understanding Scratch

Never mind

Last edited by MrBeans1307 (June 5, 2024 19:00:43)

Koamodo975
Scratcher
1000+ posts

Help with Understanding Scratch

MrBeans1307 wrote:

How to make gravity
whenclickedforeverchange~Y speedby-2changeyby~Yspeed
Just gravity
Please don't necropost.
MrBeans1307
Scratcher
7 posts

Help with Understanding Scratch

Koamodo975 wrote:

MrBeans1307 wrote:

Never mind

Last edited by MrBeans1307 (June 5, 2024 18:59:19)

Powered by DjangoBB