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

#1 2010-10-04 08:39:14

tansaku
New Scratcher
Registered: 2010-10-04
Posts: 4

Macro Recording of Movements

Hi All,

So I'm trying to teach my 5 year old son programming using Scratch and one thing I thought of that would be really cool, was if you could move a sprite in some kind of macro-record mode, and that would generate a little program block.

Whaddya think?  Can it be done? Has it been done already?

Many thanks in advance
CHEERS> SAM

Offline

 

#2 2010-10-04 09:53:18

JTxt
Scratcher
Registered: 2010-05-19
Posts: 100+

Re: Macro Recording of Movements

You can record actions to lists...

Here's a simple example, using two lists and a variable:

When I receive "record":
delete [all] of (list.mouse.x)
delete [all] of (list.mouse.y)
forever
  Add (mouse x) to (list.mouse.x)
  Add (mouse y) to (list.mouse.y)

When I receive "playback":
set [i] to (1)
forever
  Go to x: (item (i) of [list.mouse.x]) y: (item (i) of [list.mouse.y])
  Change [i] by (1)

--------------------
And here's a more complicated example I made.  It records changes just when there is mouse movement to one list, records faster when clicking/drawing, and saves the timer, so that it can be synced to audio( recorded with another program then added to scratch later). 

and here's another for more general use: it's more of a framework I'm working on to record and playback anything.  I'm working on a screen-cast like demo made with it.  (multiple mouses is more of a test than practical.)  It could also be expanded and used to record puppet like animation.  slideshows, music notes, record and playback gameplay....

Last edited by JTxt (2010-10-04 10:30:16)


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#3 2010-10-04 16:34:36

tansaku
New Scratcher
Registered: 2010-10-04
Posts: 4

Re: Macro Recording of Movements

very cool.  I think I see how this could work to achieve what I want.  I'm pretty new to scratch.  Any chance you could send a screen shot of that code in the code builder?  I'm a little unsure of what block to use for some of the commands.

Many thanks in advance

Offline

 

#4 2010-10-04 16:48:05

tansaku
New Scratcher
Registered: 2010-10-04
Posts: 4

Re: Macro Recording of Movements

Actually I can get most of the way, but I can't seem to chose the i'th element from the list.  My only options appear to be numbers, last or any. I would embed this image, but I"m not allowed to - perhaps you can just click on the link to see it ...

http://lilt.ics.hawaii.edu/~srjoseph/scratch.jpg

I am using Scratch 1.4 on OSX 10.6.4

Offline

 

#5 2010-10-05 02:50:38

JTxt
Scratcher
Registered: 2010-05-19
Posts: 100+

Re: Macro Recording of Movements

tansaku wrote:

Actually I can get most of the way, but I can't seem to chose the i'th element from the list.  My only options appear to be numbers, last or any. I would embed this image, but I"m not allowed to - perhaps you can just click on the link to see it ...

http://lilt.ics.hawaii.edu/~srjoseph/scratch.jpg

I am using Scratch 1.4 on OSX 10.6.4

http://lilt.ics.hawaii.edu/~srjoseph/scratch.jpg

You just about have it!
You just need an orange (i) variable inside the go to, like this: 
go to x: (item (i) of [list.x]) y: (item (i) of [list.y])

so that is goes to item (i) from the lists... it starting at one, and then goes to the next...
Makes sense?


Other list tips:
If you record for a long time, adding too many items to your lists, you may find your scratch save file takes a long time to open and close.  You may want to put a delete all from your lists before you record, and stop when done recording. 

Also, if you don't need the recording to be as smooth, you can slow the rate it saves to lists, by putting a [wait for] block in with the record and play back loops (forever).

If it tries to read an item number from the list that is too high, it will suddenly stop your script when viewed online.  That will happen with your script how it is now when it gets to the end while playing back.  But that's ok here because it's done anyway.  Just keep that in mind when you make things more complicated and wonder why your list scripts are broken online.


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#6 2010-10-05 04:59:05

tansaku
New Scratcher
Registered: 2010-10-04
Posts: 4

Re: Macro Recording of Movements

JTxt wrote:

You just about have it!
You just need an orange (i) variable inside the go to, like this: 
go to x: (item (i) of [list.x]) y: (item (i) of [list.y])

so that is goes to item (i) from the lists... it starting at one, and then goes to the next...
Makes sense?

Perfectly - just tried again and I was able to drop the i variable into "item ... of list ...".  Many thanks.  Now I have to try and smooth this all out so my son can use it ...

What I'd really like is if the Scratch code could generate other Scratch code to represent the movements in the list.  It's not so much that I want to be able to replicate a movement per se, but that I want my son to indicate what he wants by moving a sprite, and then seeing code blocks appear that represent that, so he more strongly gets the sense of the relation between the movement and the code blocks ...

CHEERS> SAM

Offline

 

#7 2010-10-05 10:28:13

JTxt
Scratcher
Registered: 2010-05-19
Posts: 100+

Re: Macro Recording of Movements

tansaku wrote:

What I'd really like is if the Scratch code could generate other Scratch code to represent the movements in the list.  It's not so much that I want to be able to replicate a movement per se, but that I want my son to indicate what he wants by moving a sprite, and then seeing code blocks appear that represent that, so he more strongly gets the sense of the relation between the movement and the code blocks ...

ok, cool.
I don't know of a way to generate code within scratch.  That may be a neat feature.  (BYOB, a mod of scratch, can have blocks inside lists, but that probably wont help you.)

For now, other than recording to lists, I think the option to is to make an example by hand, and just play with the movement blocks, learning the x y coordinates and the sequence of actions that way...
there's also "single stepping" in the edit menu that highlights the current blocks. 
Good luck!

Last edited by JTxt (2010-10-05 10:30:34)


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

Board footer