Version 1.4
Have you ever wanted to make cool games on scratch??Well this tutorial will show you how!
CONTENTS
-Basic Animation
-Looks and Effects
-Loops,Booleans
-Math and Numbers
-Controlling
-Sounds
-Pen
-Variables and Lists
-Scratch Board
Chapter 1 - Basic Animation
So..you want to make your own projects on Scratch?
Lets start with movement;that's really simple
Open Scratch,you will see a cat.This cat is the Scratch mascot.Now let's give him some movement
Copy this script into the cat.
Now click the green flag!The cat moved!!
How did it happen?
First the yellow block means that the following actions will happen when the flag is clicked.Then the makes sure the cat goes to his original position before running.You can change that to any other coordinate.Finally the block tells the cat to move smoothly to that position.
Lets try some thing harder .Now click the green flag and try pressing the left or right keys.
The cat moves when you decide to!Awesome!!
How did it work?
First,he comes to the center,just like he did on our first script. means that the actions connected will execute when a certain key is pressed.The block changes the x coordinate of that sprite.
Always remember this:
-ALL scripts start with a ''hat'' block such as the ones used above
-If you but a negative number on ''change x by'' blocks he will go backwards
Time for something funner
Copy this script into the cat
Press the green flag and use left or right keys.So,what happened?
The cat rotates as he moves!Fun eh?
First he comes to the center and point to the direction right.The ''turn ## degrees'' comes in two directions.We used both on this script.Also the ''move ## steps'' moves the sprite as well but only in the direction he is pointing to!
Remember the directions:
0:up
90:right
270(-90 in Scratch):left
180:down
Chapter 2 - Looks and Effects
In this chapter we will learn about the ''looks'' in Scratch Blocks
Copy this into the cat.Now click the green flag and press the space bar a few times.Whoa!!The colors changed!!Magic??Yes,programing magic!How?
First,the script removes all the graphic effects.Then,when you press the Space Bar,the color effect is changed by 25.
Try changing that to other effect, such as Whirl,or Ghost.
There's a list of Scratch's effect blocks:
-Color
-Fisheye(makes center of sprite bigger)
-Whirl
-Pixelate
-Mosaic
-Brightness
-Ghost(transparesy)
These blocks can be used to change costumes,or for dialogs.
Try copying this script and running it.Then press space some times.
Now he moves really well.How did that happen?
First,it comes to the center, and it changes to it's first costume.Then he salutes us, and tells us how to move him
Then,when space is pressed, the costume changes, and he moves to the right.
The first three blocks, can be used to change a sprite's size. This, along with layering (look below), is often used to create the illusion of the so-called ''3D Games'' (yup, just a illusion. 3D is not supported by Scratch..sorry).The last two blocks are simple,but really useful: They show or hide a sprite. This is good for, say, when you want a certain sprite to appear after something happens.When a sprite is hidden, it can't execute ''When clicked'' commands.
These two blocks are used for layering.What's that, you ask?
When you use ''go to front'' , the sprite shows in front of all sprites.When you use ''go back [#] layers'' , he goes below the sprites. So layering, involves the order in which the sprites show up.
Chapter 3 - Loops, Booleans
On this chapter we will cover Loops, and most of the Sensing blocks.
A loop on Scratch ( and other programming languages ) is a series of commands that repeat.
Let's try a simple loop:
Whoa, that's nice!!There are 4 kinds of loops:
Forever
Repeat [#]
Forever if
Repeat Until
On this one we used Forever.
Forever repeats something forever:Since it starts until you press the red Stop button, or use a stop all block.
Forever if repeats something only if a boolean (see chapter 2) is true.Repeat until is the opposite, it repeats something until a boolean is true. Repeat [#] repeats something the times you specify.
A boolean (or bool) is a true/false value.
If you go to the ''Sensing'' section, you'll find lots of boolean to use.
Remember our first movement script on Chapter 1?...Let's improve it.
(please note that this is a image because i could not code the scrip using the blocks given on the forums)
This is a smoother version. You should use this one.
Okay. So, loops that require booleans work when the booleans is true.
But.. what if I want it to run when it's false? Simple. Go to the numbers section and use the ''Not'' block. You'll also find a ''And'' ( two booleans need to be true) and ''Or'' (two possibilities)
Remember, the type of blocks in Scratch is defined by their shape:
-Hat blocks: They start it all
-Normal: Command
-Diamond: Boolean
-Round: Number
-C: Loop
Chapter 4 - Math and Numbers
Math? You hate math!!? I know I do too, but if you do close this you will regret it.
Math is a basic component of Scratch projects. Many great projects, even some of the simple ones need a mathematical formula.
Example: Let's say you want to calculate the score, using the enemies killed AND the time left ( okay, that does involve variables, we'll see them in an other chapter)
There. This script, when the game's over, calculates the score multiplying the Time Left by the Enemies Killed.
And divides the result by 2. Here we got a formula.
Go to the ''Numbers'' section, you'll find lots of math blocks.
These are the basic Math blocks:
If you already took 4th grade, you should obviously know the first four.
The 5th one picks a number at random. Good for chance games.
These are also a it obvious: Smaller then, Equal to,Greater then.
These (ones below) aren't really ''Math'', but they're still good for our formulas, as they can change the sense of a script.
Below are some more complex blocks.
Honestly, I do not know much about these, but subzerostig told me about a few!
Abs means absolute value, and turns all numbers into a positive one.
-7 turns to 7 & 7 turns to 7
The round function rounds the number to the nearest 1.
2.5=3
2.49=2
3.9=4
3.1=3
That's quite simple.
The mod function mod gives the remainder of a number.
6 mod 4 = 2
13 mod 6 = 1
4 mod 2 = 0
e^'s official term is the base of natural logarithms. You can use it to tell how something grows.
e^ means e to the power of ()
e roughly equals 2.7 so e^ of 2 means 2.7*2.7 e^ means 2.7*2.7*2.7
However, e^ can be a decimal.
You can use it in advanced formula's to work out how your money grows.
You would use this formula:
pert
If you want to find out more about the others, then ask a few people and see if they know!
Chapter 5 - Controlling
This time we will cover the ''Control'' section. They're the key to have a good game, of course, along with many more aspects of Scratch.
Go to the Control category, and create another sprite, we'll use it later
Broadcasts are essential for good games. How do they work? Basically, a sprite sends a message to another, and the other executes a script.
Now, put this script on the first sprite:
And this one on the second:
Now click the green flag. If Sprite2 said ''Received!'', you did it well. Congratulations!
The ''broadcast [---] and wait'' broadcast a message, and any command after the block will execute once all block receive the broadcast.
These two blocks can be used to end scripts. The first ends the current script, while the second stops everything.
Try this script, and run it. The sprite will constantly change it's colors, until you press Space, to stop all scripts.
These blocks allow you to wait between two commands. The first, ''wait [#] secs'' waits the amount of seconds you specify before executing other commander. The second, waits until a boolean is true before executing other commands.
Chapter 6 - Sounds
Sounds are an important part of Scratch projects; they brink it to life(not really ). On this chapter we'll learn how to give or projects sound.
Select a sprite, and click on the Sounds tab. You'll see all the sprite's sounds. By default, the Scratch Cat sprite includes only one sound: ''meow''. Try playing it with the play button. You'll hear a cats meow. Now, lets play it with a script.
The ''play sound'' block plays the sound you select. ''Play sound until done'' play it as well, but before executing any block after it, the sound must finish.
''Stop all sounds'' is self-explanatory
You'll find some MIDI blocks as well.
The first block plays a drum. MIDI drums are numbered from 35 to 81. The second is like a wait block, but using beats rather than seconds. The third plays a MIDI note, from 0 to 127, but a good range is from 48 to 72; about 2 octaves. The last sets the instrument for the ''play note'' block to use. There are 128 instruments. That sounds like a lot
Try composing a simple melody with the blocks. Here's a simple beat I made, below
The first two blocks change the volume of the project. 100 is the maximum volume. The last two change the tempo of the MIDI blocks. The tempo is measured in beats per minute (bpm, DUH ). So, a tempo of 60 means every beat dures 1 second.
Chapter 7 - Pen
Pens aren't usually used on projects, but they're good for Paint Programs(Yep you can make these on Scratch ).
On this chapter we'll cover the Pen section and it's blocks.
Copy this script:
Use any color you want. Press the green flag, then, move and click your mouse.
You just made a cool pen script It's perfect for Paint Projects. How did it work?
First it clears everything you drew. Then it always goes to the mouse, and if you click the mouse the pen is Down (It draws ), but Otherwise, it's Up (It does not draw).
But remember, each sprite has it's own pen, and it's own pen color, size, etc.
So if you wanted, a sprite that when clicked gives another color, you'd have to use broadcasts.
You can make it so the computer draws a picture by itself.
Let's try drawing a square using this script, then run it.
It drew a square. But wait, you can make it faster. Try changing the seconds.
There's another simple programming language which has a really powerful pen as well. It's called Logo, you might want to try it.
Here's the Logo interpreter
Chapter 8 - Variables and Lists
Variables are essential part for good projects. Lists are really useful in some.
A variable, as their name indicates, is something that varies. It can be anything, the score, the lives, ammo, costume numbe, or anything else. That is, if you use the script well. Try going to the Variables category, and create a variable called ''costume''. There are two types of variables: ''For all sprites'' and ''For this sprite only''. Pick the first one.
On the Stage, use this script:
On Sprite 1, use this script:
Then run it. If you did it well, Sprite 1 will constantly change it's costume.
List are in the same category. Basically, a list is a group of variales. You can use it for whatever you want, as well.
Let's say you want to use it as a Inventory, and want to check if the first item is ''Key''. Use this:
The only way for Scrath to handle strings (lines of letters) is using another variable, and setting it to a string.
But, what if you want to check every single item? Use this:
(set[action?] to [1] isn't really necessary, the broadcast is enough)
Chapter 9- Scratch Board
First off, sorry for the years worth of delay, I got lazy
Second off, if you don't own a Scratch Board (or PicoBoar, both are the same), you'll not be able to test out scripts on this Chapter.
I own one, but I bearly ever use it so I'll try to be as precise as possible on this.
Look at these blocks on the Sensing category:
We got a variable and a boolean there.
The variable is used to check the value of a sensor. You'll ask: What? Well, the Scratch Board has a set of sensores used to connect Scratch to our world.
The Sensors used by the Board are....
1-Slider: A simple slider. It's value varies between 0 and 100 depending on the slider's position
2-Light: A light sensor. It's value is 0-100 depending on the light around the it. (0= dark room, 100= direct light.)
3-Sound: It works just like a mic, and therefore just like the ''Loundness'' block.
4-Resistance: There are 4 of them on the board. Each one is a cable with two metallic ends, when they touch, it gives a value. The harder you press, the higher value.
So, what's the boolean for? It has 2 options, checking if the button is pressed, or if a sensor is connected.
Here is a simple script to check if a sensor is connected.
A Scratch/PicoBoard is a great way to interact with Scratch. Just imagine the possiblities! You could make a adventure game where you move using the slider, and use real light to lit up dark areas, or the button and the resistance sensors to interact with objects.
Also, a fun thing to do is creating custom sensors using these resistance sensors. You could make a cardboard gun using a resistance sensor as the trigger and the slider to aim. Or maybe a steering wheel, using two resistance sensors on the sides, with a system so when you steer the wheel, something activates the risist. Sensors (ex: a Strong piece of cardboard). You can make just about any sensor with the resistance sensors, as long as you have enough materials, and creativity.
If you're unsure of what a block does, right click it, and click on ''help'' to see a short definiton.
Well, this is the last chapter until 2.0 so I have to give credit where it is due; technoguyx for all the information
Also sadly 1.4 will be the last version of this guide until Scratch 2.0 is out, other then the occasion when I find more on the only non complete chapter other then Scratch Board, Math and Numbers! Thanks for reading this!
Last edited by maail (2011-02-17 11:15:04)
Offline
Chrischb wrote:
I think to imitate the ITopic thing.
How so?
Also, great guide, but the blocks are really messed up for me. You should try using that function that lets you take pictures or Scripts, and put them up instead
Offline
Blade-Edge wrote:
Chrischb wrote:
I think to imitate the ITopic thing.
How so?
The title was "I-Topic All About Scratch" earlier - it got changed back now...
Last edited by Chrischb (2010-07-08 05:10:37)
Offline
Chrischb wrote:
Blade-Edge wrote:
Chrischb wrote:
I think to imitate the ITopic thing.
How so?
The title was "I-Topic All About Scratch" earlier - it got changed back now...
Okay then.
Have you answered my question about ITopics yet?
Offline
Blade-Edge wrote:
Chrischb wrote:
Blade-Edge wrote:
How so?The title was "I-Topic All About Scratch" earlier - it got changed back now...
Okay then.
Have you answered my question about ITopics yet?
What question?
Offline
I think that this should be a permanent sticky, that's what I think.
Offline
Ah - I think I can explain why the topic name hasn't been changed. Because "ITopic" is a special tag given to certain threads, we moderators have to discuss with each other and the Scratch Team before we put the tag on a topic title. This is a really nice guide though - perhaps when it's completely finished, we'll consider it for the ITopic tag
Offline
Wolfie1996 wrote:
Ah - I think I can explain why the topic name hasn't been changed. Because "ITopic" is a special tag given to certain threads, we moderators have to discuss with each other and the Scratch Team before we put the tag on a topic title. This is a really nice guide though - perhaps when it's completely finished, we'll consider it for the ITopic tag
I see thanks for the help, Wolfie1996
Offline
Awesome guide, If you finish it it should be stickyed!
Offline
Great! This wil help lots of new Scratchers! This is a great thing you are doing, maail.
Offline
maail wrote:
Chrischb wrote:
I'll be sure to keep an eye on this.
Really, thanks, sadly the next upload may be a long time away but I am already started!
Such courage! I could never follow through with this. Awesome!
Offline