This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-03-09 20:51:12

dsdude10
Scratcher
Registered: 2007-09-22
Posts: 500+

Scratch Tutorials

Welcome to some of my tutorials for scratch.  If the tutorial you need isn't here, just comment below asking for it.
Let me start by answering a lot of 'how do you do' questions that I see on the forums a lot.

Gravity
Gravity is pretty easy to make once you know how.
Put together a script as shown below.
http://i43.tinypic.com/1z65nc2.gif

(OPTIONAL)
If you would like to make more accurate sensing, copy the main costume of your sprite.
http://i44.tinypic.com/jzin0h.jpg
Then right click the copied costume and turn it into a new sprite.
http://i43.tinypic.com/51aq1f.png
Edit the costume and draw a line where you would like the sprite to stop when the line touches the ground.
http://i39.tinypic.com/2lszl7q.png
Then using the rectangle tool, select the gray and white checkered color of the color chart on the bottom left corner of the paint editor and make two rectangles, one above the green line, and one below it, covering the character but not harming the line.
http://i41.tinypic.com/9pu900.png
Press 'OK' and then put together a script as shown below for the line's scripts.
http://i40.tinypic.com/11vmk3a.gif
Go back to the sprite you control and add this to the script.
http://i41.tinypic.com/15d9hy1.gif

...And there you go! That's a good way to do gravity without getting too advanced.  Let me explain how it works.
The variable 'Y Velocity' changes the Y position of the sprite.  When it's not touching the ground, it changes the 'Y Velocity' variable by -1, causing the sprite to go down faster and faster.  But when it's touching the ground, it sets it to 1.  Why not 0? Because when it's 1, it changes the Y Velocity variable by -1 setting the variable to 0 and since the sprite is still touching the ground, sets the y velocity variable to 1 and it keeps on doing that causing the sprite not to move.  The reason the other script was added is to keep the sprite to sink into the ground when it hits it.  When the sprite jumps to the ground from a high area, he goes down a little into the ground until he stops.  The invisible line that goes to him forever fixes that.  When the invisible line touches the ground, it sets a variable to 1, causing the other sprite to change it's Y position by 5, until the invisible line isn't touching the ground.

(NOTE: In the pictures with comment blocks, the comment blocks are behind the script, the two different comment blocks say, (Color of Ground), and, (Sprite Name). Sorry about that happening, it won't happen in the next tutorial I make)

If you didn't understand something, please comment.

Hoped this helped you,
dsdude10

Last edited by dsdude10 (2009-03-09 20:53:43)

Offline

 

#2 2009-03-11 21:40:16

dsdude10
Scratcher
Registered: 2007-09-22
Posts: 500+

Re: Scratch Tutorials

please comment if you want me to make other tutorials

Offline

 

#3 2009-05-25 13:30:16

svinnik
Scratcher
Registered: 2008-08-31
Posts: 1000+

Re: Scratch Tutorials

Um well I need some help with platforming.


http://www.harkavagrant.com/msnpaint/rabies.jpg

Offline

 

Board footer