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

#1 2008-01-27 21:45:15

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Programming the scratch blocks

Hey Scratch makers, (people who helped program the scratch blocks) how did you program a block that we use for other programming? becuase heres my question:
you have to program the block to do stuff right? so id be like this

                   <move(  )steps>

                To program that block id say somehting. what does it say?


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#2 2008-01-27 23:04:45

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Programming the scratch blocks

Heybrian wrote:

Hey Scratch makers, (people who helped program the scratch blocks) how did you program a block that we use for other programming? becuase heres my question:
you have to program the block to do stuff right? so id be like this

                   <move(  )steps>

                To program that block id say somehting. what does it say?

That one isn't too hard to make and I made a demo of how to make it with trig functions.

and the code is,

change x by sin of direction
change y by cos of direction

This will make a sprite move 1 unit.

The distance to block was created using the Pythagorean theorem.

In this example I will find the distance between spriteA and spriteB

distance= square root of ( (x position of spriteA - x position of spriteB)^2 +  (y position of spriteA - y position of spriteB)^2)


And the point to block was probably made using the atan2 math function

I will make spriteA point to spriteB

angle = Math.atan2( -(y of spriteA - y of spriteB),(y of spriteA - y of spriteB))
rotation = 270-angle

Thats the way I would program things.

Last edited by archmage (2008-01-27 23:20:57)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2008-01-27 23:33:15

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: Programming the scratch blocks

but the thing is, you have to program what those say right? and are they bricks too?


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#4 2008-01-27 23:39:00

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Programming the scratch blocks

No, I am pretty sure the blocks are programmed in the squeak language.

I mentioned some of the ways that could be used to program some of the blocks in my above post. The programming I mentioned could also be applied to blocks (except point to because it requires atan2).

Last edited by archmage (2008-01-27 23:47:51)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#5 2008-01-27 23:41:41

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: Programming the scratch blocks

so what the heck is that?ive heard of it. i think you like make blocks? i saw it in this "flip" project.


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#6 2008-01-27 23:47:16

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Programming the scratch blocks

Squeak is the language that scratch was programmed in. If you know squeak you could program your own blocks in the open source version of scratch.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#7 2008-01-27 23:52:34

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: Programming the scratch blocks

ooohhhhh. ...... so scratch is just an easier method of programming?


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#8 2008-01-28 00:03:07

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Programming the scratch blocks

Scratch was meant to be a simple language that anyone could easily pick up. It is easy to learn but you can use it to make complex programs if you wanted.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#9 2008-01-28 11:53:02

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: Programming the scratch blocks

Yeah, i think blocks like move()steps are way easier then that sin and cos stuff you were talking about!  wink


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#10 2008-01-28 12:10:22

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Programming the scratch blocks

In other languages you have to ype the commands - every mistake is a bug. Scratch is a "new" way of programming - you drag blocks together instead of typing code.

an example:

this is (easy!) flash action script code:

Code:

sprite1.onRelease = function() {
  for (i=0; i<360; i++) {
    this.direction = this.direction + 1
  }
}

This is (almost) the same thing, but in scratch:

code wrote:

---
[blocks]
<when[ sprite 1 ]clicked>
<repeat( 360
<turn cw( 1 )degrees>
<end>
[/blocks]
---

What do you think is the most easyest?


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#11 2008-02-04 15:04:58

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Programming the scratch blocks

how do you get the open source version of scratch?


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#12 2008-02-04 19:44:42

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: Programming the scratch blocks

to jso, I THINK SCRATCH IS EASEIR LOL! that looks so hard! to blob, its called squeak.


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

Board footer