Discuss Scratch

jelhai
New to Scratch
8 posts

Snap! user discussion

Mayhem from cloning sprites

I can't seem to avoid the mayhem that results from trying to work with multiple sprites and their clones. There seems to be no way of avoiding asynchronous execution, which in my hands leads to erratic outcomes. For example, I want to display a game board consisting of a grid of hexagonal cells with one number superimposed on each cell. The Scratch game I'm using as a model accomplishes this by uploading costumes corresponding to every possible cell. Ugh! I can't live with this solution, as (for on thing) it limits the choices of teachers who may wish to modify the game for different audiences.

My solution was to make a hexagon sprite (with costumes of different colors) and a text sprite (basically a font). I've written code to display a cell (each a clone of the prototype hexagon) and then very crude code to display the appropriate text over it (each digit a clone of the text sprite). At every cloning event, the clone sets a local ID variable, which I use later to delete the clone.

The key problem is that I don't know how to control the sprites except by broadcasting a signal that is received by all of them. This is grossly inefficient – with each additional digit there is another clone to hear the request to make a new digit. I've controlled that by making the script monitor an external variable that allows it to determine if it is the first clone hearing the message. This all is horrifically ugly and also leaves it to chance which clone generates the next clone. I think this is the cause of an immediate symptom of my confused scripts – the order of clone creation bears little resemblance to the IDs the clones possess. Worse, the IDs of the clones change over time as further clones are created.

I have no theory that explains the behavior, but I'm convinced it would all go away if functions could directly affect clone properties (e.g. the values of their local variables) without needing to broadcast messages to all clones.

I've tried to understand the various grains that have been tossed periodically concerning the “…BYOB 3.1-style (inheritance-based) cloning in Snap! 4.1”, but I confess I can't tell whether this new feature will address the problem I've described. Whether it does or not, is there any estimated time of arrival?

Thanks.

P.S. I see that the URL tags I put in my last message didn't create links. Here are the URLs:

Top level script: http://www.people.vcu.edu/~elhaij/transfer-2/151105-Div-Dash-begin.gif
Play an instance of the game script: http://www.people.vcu.edu/~elhaij/transfer-2/151105-Div-Dash-play-game.gif
bharvey
Scratcher
1000+ posts

Snap! user discussion

vostok_st wrote:

where is a developer who can easily show it to me.
We have two different Snap!-Arduino packages, this one and that one.

bharvey
Scratcher
1000+ posts

Snap! user discussion

jelhai wrote:

but I'm convinced it would all go away if functions could directly affect clone properties (e.g. the values of their local variables) without needing to broadcast messages to all clones.
You can do this:

to tell a particular sprite to run a script.

It's easy if you want the parent sprite to do it. If you want to address an individual clone, you'd have to know its name. When I try it, the right pulldown of OF includes the name “close” (is that a misspelling of clone?) and when you choose it, you see nothing in the pulldown box, but the script is run by one of the clones (the first one?).

What 4.1 will do is make sprites first class data, so you can have a list of all the clones of a sprite, and refer to them directly rather than by name.

scratchmouse
Scratcher
70 posts

Snap! user discussion

Hi to Brain I like this typo because it's a charming little Freudian slip ,
ok, Brian and Jens and other great folks here who will undoubtedly be able to answer my question.

I saw that (on Oct 25 on Twitter) Jens shared a project - see (add the usual url prefix to /moenig/status/657881853836136448 and I hoped there will be a new block in the project, something like the Scratch's
 set pen color to () 
with parameters R, G and B.
.
Is it possible to make such a block at all, or there are only 200 (not the whole RGB spectrum) colors in Snap! I wonder if Snap can be modified to be able to have the whole RGB spectrum of colors?

Thanks in advance!

˙˙˙ ˙˙ ˙Ignore˙ ˙˙ ˙˙˙

… .. ˇˇˇ ˇˇˇ ˇˇˇ ˇˇˇ .. …
::: :: … ˇˇˇ ˇˇˇ … :: :::
Jens
Scratcher
100+ posts

Snap! user discussion

You can get a lot of colors in Snap just using the plain old Scratch-like color codes:

http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=Colors&editMode

You can also compute both RGB and HSV to and from these color codes in Snap itself:

http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=rgbMixer&editMode

With just a little bit of JavaScript you can make your own pen enhancements for every color (and more):

http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=pen%20enhancements&editMode

… and also play with full-blown pixel manipulation in Snap itself:

http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=MediaComp&editMode

Feel free to reuse any of the custom blocks in these demo projects!
bharvey
Scratcher
1000+ posts

Snap! user discussion

scratchmouse wrote:

Hi to Brain I like this typo because it's a charming little Freudian slip
People have been doing this since I joined the Cub Scouts at age 8 and they spelled it that way on my membership card. (I didn't last long btw.) My first time in Australia, I met a kid (still a good friend) who pronounced my name “Brawn,” which made a nice contrast.

scratchmouse
Scratcher
70 posts

Snap! user discussion

Jens wrote:

(…) pen enhancements for every color (and more):
http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=pen%20enhancements&editMode
(…) Feel free to reuse any of the custom blocks

Thank you, Jens, that was quick!

I still need a bit of help, though.

I have no idea how to re-make the set_pen_line_ends_to block the same way you made it.

How do you make the input to be drop down? Thank you again.

˙˙˙ ˙˙ ˙Ignore˙ ˙˙ ˙˙˙

… .. ˇˇˇ ˇˇˇ ˇˇˇ ˇˇˇ .. …
::: :: … ˇˇˇ ˇˇˇ … :: :::
liam48D
Scratcher
1000+ posts

Snap! user discussion

scratchmouse wrote:

Jens wrote:

(…) pen enhancements for every color (and more):
http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=pen%20enhancements&editMode
(…) Feel free to reuse any of the custom blocks

Thank you, Jens, that was quick!

I still need a bit of help, though.

I have no idea how to re-make the set_pen_line_ends_to block the same way you made it.

-snip-
I think you need to right click on the input in the input selection box and select “options”. Then fill in the options you want. You can also mark it as read only in the same right click menu.

202e-202e-202e-202e-202e UNI-CODE~~~~~
Hardmath123
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

scratchmouse wrote:

Hi to Brain I like this typo because it's a charming little Freudian slip
People have been doing this since I joined the Cub Scouts at age 8 and they spelled it that way on my membership card. (I didn't last long btw.) My first time in Australia, I met a kid (still a good friend) who pronounced my name “Brawn,” which made a nice contrast.
That reminds me of this Arthur episode where the Brain's name is misspelled as “the Bran”.

I think it's kind of sad how I know the scripts to so many Arthur episodes verbatim…
bharvey
Scratcher
1000+ posts

Snap! user discussion

Hardmath123 wrote:

I think it's kind of sad how I know the scripts to so many Arthur episodes verbatim…
Right, it should be Animaniacs! episodes. And Pinky and the Brain, which for a moment was what I thought you were talking about.

Jonathan50
Scratcher
1000+ posts

Snap! user discussion

Hardmath123 wrote:

I think it's kind of sad how I know the scripts to so many Arthur episodes verbatim…
xD I've never seen an “Arthur” episode before
I don't see how that is sad though…
Edit: http://arthur.wikia.com/wiki/Arthur_Wiki?file=All_About_ARTHUR

Last edited by Jonathan50 (Nov. 7, 2015 03:12:31)


Not yet a Knight of the Mu Calculus.
xly
Scratcher
100+ posts

Snap! user discussion

Jens wrote:

You can get a lot of colors in Snap just using the plain old Scratch-like color codes:

http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=Colors&editMode

You can also compute both RGB and HSV to and from these color codes in Snap itself:

http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=rgbMixer&editMode

With just a little bit of JavaScript you can make your own pen enhancements for every color (and more):

http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=pen%20enhancements&editMode

… and also play with full-blown pixel manipulation in Snap itself:

http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=MediaComp&editMode

Feel free to reuse any of the custom blocks in these demo projects!

May I contribute with a colour picker ?

http://snap.berkeley.edu/snapsource/snap.html#present:Username=xleroy&ProjectName=ColorPicker
xly
Scratcher
100+ posts

Snap! user discussion

@Jens, scratcmouse and others

I've put together in this project several color blocks (conversion for example between rgb, hue, hexa etc)

http://snap.berkeley.edu/snapsource/snap.html#present:Username=xleroy&ProjectName=46-colist

Far from the elegance of Jens code, but no human can aim to be a god !
jelhai
New to Scratch
8 posts

Snap! user discussion

Problem playing uploaded sound files in Snap! running in Chrome

Does this make any sense?

Running Snap! in Chrome:
  • Sample sound files (those provided built-in from the menu on the upper bar) play as expected.
  • Nominally the same files (WAV) obtained from a Scratch project and uploaded into the Sounds tab do not play. For example, chord.wav from Scratch doesn't play. It starts but makes no sound and never stops.
  • It's not a WAV problem. An MP3 file taken from https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3 starts but makes no sound and never ends.

This appears not to be a Chrome problem, because the files play fine from their original sources (Scratch or the above test site) run in chrome

This appears not to be a Snap! problem, because if I run Snap! in Firefox, the uploaded files play fine.

The problem appears confined to files uploaded into Snap! running in Chrome. I wish I could test this by downloading one of the sample sound files and then upload it back to see if it is unable to play after the return trip. Unfortunately, there appears to be no way to download a sound (unlike a costume)..

Thanks.

Last edited by jelhai (Nov. 8, 2015 02:35:51)

bharvey
Scratcher
1000+ posts

Snap! user discussion

jelhai wrote:

Nominally the same files (WAV) obtained from a Scratch project and uploaded into the Sounds tab do not play.
Could you be more specific about the sequence of steps? You took a Scratch project and asked Scratch to extract a sound from it, or you ran the project through Snapin8r, or what? Thanks.

comp09
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

jelhai wrote:

Nominally the same files (WAV) obtained from a Scratch project and uploaded into the Sounds tab do not play.
Could you be more specific about the sequence of steps? You took a Scratch project and asked Scratch to extract a sound from it, or you ran the project through Snapin8r, or what? Thanks.
The sounds produced by Scratch are in ADPCM format, which is not supported by most browsers.


Visit the website of Andrew Sun!


bharvey
Scratcher
1000+ posts

Snap! user discussion

comp09 wrote:

The sounds produced by Scratch are in ADPCM format, which is not supported by most browsers.
Oh. Wow, if I'm understanding Wikipedia correctly, that's how they used to squeeze speech from lots of telephone conversations into the same cable. In speech they don't care about anything outside 300-3000 Hz; in fact it's easier to understand speech (although not to recognize voices) if you suppress frequencies outside that range. Why does it make sense to use it for non-speech sounds in these days of all the bandwidth in the world (by audio standards)?

Also, how come Scratch (running in a browser) can… oh, let me guess, there's software for it in Flash.

MathWizz
Scratcher
100+ posts

Snap! user discussion

bharvey wrote:

Also, how come Scratch (running in a browser) can… oh, let me guess, there's software for it in Flash.
Actually, the ST did have to write their own ADPCM decoder because flash doesn't support it either.

running Chromium 42.0.2311.90 with Flash Player 15.0.0.189 on Arch Linux 3.19.5-1-ck
MathWizzJsScratch && sb.js & Amber (coming soon! maybe)
jelhai
New to Scratch
8 posts

Snap! user discussion

bharvey wrote:

jelhai wrote:

Nominally the same files (WAV) obtained from a Scratch project and uploaded into the Sounds tab do not play.
Could you be more specific about the sequence of steps? You took a Scratch project and asked Scratch to extract a sound from it, or you ran the project through Snapin8r, or what? Thanks.

I could describe the steps, but never mind. Forget about Scratch. The file I downloaded plays perfectly well in Snap! running in Firefox and plays just as well in Chrome when I play it from a web site (http://www.people.vcu.edu/~elhaij/transfer-2/AGT%20Buzzer%20Sound.wav).

But to simplify, I took a wav file (chord.wav) from Microsoft Windows (no doubt a genuine wav file) and put it on the web (http://www.people.vcu.edu/~elhaij/transfer-2/chord.wav). It plays fine when accessed directly in Chrome and Firefox. When I transfer the file into Snap!:

  • In Snap! running under Firefox, the file appears in the Sounds tab, where I put it. Clicking Play causes Play to be replaced by Stop, the sound is made, and Stop changes back to Play. All as it should be.

  • In Snap! running under Chrome, the file appears in the Sounds tab, where I put it. Clicking Play causes Play to be replaced by Stop, but no sound is made, and Stop never changes back to Play, If I attempt to play the sound via play sound until done, the block begins execution but never terminates.

Surely other people have transfered sound files into Snap! running under Chrome. Does it work for them? For what it's worth, Chrome is Version 46.0.2490.80 m.

Thanks.
scratchmouse
Scratcher
70 posts

Snap! user discussion

Jens wrote:

(…) pen enhancements for every color (and more):
http://snap.berkeley.edu/snapsource/snap.html#present:Username=jens&ProjectName=pen%20enhancements&editMode
(…) Feel free to reuse any of the custom blocks

scratchmouse wrote:

(…) I have no idea how to re-make the set_pen_line_ends_to block the same way you made it. (…)

liam48D (Nov. 6, 2015 16:55:26) wrote:

(…) you need to right click on the input in the input selection box and select “options”. Then fill in the options you want. You can also mark it as read only in the same right click menu.
Thank you, right clicking the box at the end of the single input did the trick, however, to make it more visible it could be placed at the same level (I know that strictly-logically wise, it does belong where it was placed… but maybe you can move it as an act of kindness/concession to inexperienced users/user friendliness) so @Brian and Jens, can it be moved one level up as shown below.
  • Single input. Default value: _______
  • Multiple choice input. (maybe with additional text: Click here to enter multiple choices and/or make the entered ones read-only)
  • Multiple inputs (Value as list of inputs)
  • Upvar - make internal var. visible to caller
What do you think?

˙˙˙ ˙˙ ˙Ignore˙ ˙˙ ˙˙˙

… .. ˇˇˇ ˇˇˇ ˇˇˇ ˇˇˇ .. …
::: :: … ˇˇˇ ˇˇˇ … :: :::

Powered by DjangoBB