Discuss Scratch

Chibi-Matoran
Scratcher
1000+ posts

Snap! user discussion

Here is the video : https://www.youtube.com/watch?v=OjaAToVkoTw I remember watching it a while back.

If you see this signature while scrolling, you have been visited by ʎ++ haskal. Lazy evaluation, monads, function purity, lambdas, currying, partial application, algebraic data types, pattern matching, and typeclasses will come to you, but only if you comment, “Thanks, ʎ++ haskal” on my profile.

Cassian && ||
BookOwl
Scratcher
1000+ posts

Snap! user discussion

doloop wrote:

I recently discovered a really good YouTube video of Prof. Terence Parr of the University of San Francisco entitled How to Build a Virtual Machine found here: https://www.youtube.com/watch?v=OjaAToVkoTw&t=1694s. In it he discusses how virtual machine interpreters work and he actually builds a simple one.

I thought it would be really fun to follow along and build the virtual machine interpreter described in that video using Snap! So I did.

In the video, Prof. Parr creates a simple instruction set, builds an interpreter for that instruction set, and then codes a function in that instruction set to compute the factorial of a number. He then runs the code in his interpreter, and voila, the answer appears. It was great fun to do this and quite educational. I highly recommend this project to anyone interested in Snap! and in how computers work.

I've shared my project TParr - VirtualMachineInterpreter here: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter

And, I've created a short YouTube video showing it in operation here: https://youtu.be/Hmf57VKx-*

Enjoy!
Wow, that is a really good project! I'll have to watch the video myself.

THINK LIKE A RESCUE HERO
THINK SAFE

Check out my blog!
frodewin
Scratcher
500+ posts

Snap! user discussion

There is currently a discussion on the potential of block-based programming on response to a German Youtube video showing how to make a game with Snap! https://www.youtube.com/watch?v=kSLnwUuE3Xg

I would like to give a list of examples of excellent Snap! games. However, AFAIK there is no webpage for finding projects yet.

Can anybody provide me some links to sophisticated games made with Snap! ? They should be at the level of what Griffpatch and others are making for Scratch.

Why don't you try out some of my projects. I love to get feedback!
Click on the images to try them out.


You can find my best projects here or drop by my profile and say hi there!
bharvey
Scratcher
1000+ posts

Snap! user discussion

frodewin wrote:

Can anybody provide me some links to sophisticated games made with Snap! ?
Well, for starters, there are a few on http://snap.berkeley.edu

But also, look in YouTube for “CS 10 final project” to see what Berkeley students have done in Snap!.

frodewin
Scratcher
500+ posts

Snap! user discussion

bharvey wrote:

Well, for starters, there are a few on http://snap.berkeley.edu

Thanks for the quick reply, I already checked the projects on the startpage out, but what I found there was rather simple starter projects (Snake, Space Invaders, ) which can be good inspiration, but I meant more games at a level with like this one or that one.


bharvey wrote:

But also, look in YouTube for “CS 10 final project” to see what Berkeley students have done in Snap!.

These are some very interesting projects, thanks! Is there a list with Snap URLs or another way to get to the game? In particular I would be interested in the CS10 Final Project: the Murderer and the CS10 Final Project: A Beautiful and Joyous Quest. If not I can link to the Youtube videos which is also fine :-)


Edit: Replaced some grammar mistakes with new ones…

Last edited by frodewin (April 12, 2017 18:32:11)


Why don't you try out some of my projects. I love to get feedback!
Click on the images to try them out.


You can find my best projects here or drop by my profile and say hi there!
bharvey
Scratcher
1000+ posts

Snap! user discussion

frodewin wrote:

Is there a list with Snap URLs or another way to get to the game?
I passed this request on to Dan Garcia, who teaches CS 10.

This led to an interesting discussion in which he said “of course we'd have to track down the students and ask for permission to distribute their projects” and I said “Did they share them?” and he said yes and so I said “then they've already agreed” and he said “wait, what, they just shared them with the course staff.”

At first I thought he was just tripping but eventually understood his point, which was that since we don't have the social-media site up yet, in practice “sharing” means you get a URL that you have to email to the particular people you want to share with. But still I said “nevertheless that's what they agreed to when they checked the little ‘I have read the Terms of Service’ box” and he, with some justification, said “oh, come on, nobody reads those things.”

And then he said “that's not what anyone expects” and so I felt on firmer ground, pointing out that 99.9999% of our users are also Scratch users, and so they understand perfectly well what sharing means. And he said “well that's not what teachers expect” (because, it turns out, he was thinking about solutions to homework exercises) and I said “no, Dan, the teachers are Scratchers, too; it's just you who have this wrong expectation.”

So, I'm wondering if anyone has some evidence about this. (Alas, saying what you think doesn't count, since you are provably Scratchers. It'd have to be something like “My teacher said…” or the like.)

Oh, and then I said “anyway, why do you care about keeping homework solutions secret?” and he said “well, we have to grade them,” and I said “why? Homework is to learn from, not to prove what you already know.” And it's funny because he must have heard me say that in exactly the same words dozens of times, but he went quiet and then said “Oh. Huh.” just as if it were a new idea to him. Which speaks to me about how firmly entrenched some ideas are in the minds of teachers.

doloop
New to Scratch
15 posts

Snap! user discussion

doloop wrote:

I've shared my project TParr - VirtualMachineInterpreter here: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter

And, I've created a short YouTube video showing it in operation here: https://youtu.be/74GH0Qr9VA0

This is an effort to fix the links in my original message re making a virtual machine in Snap!

Video of Prof Parr: https://www.youtube.com/watch?v=74GH0Qr9VA0&feature=youtu.be
Snap! shared project: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter
My YouTube video of the project running (computing 5!): https://youtu.be/74GH0Qr9VA0
doloop
New to Scratch
15 posts

Snap! user discussion

doloop wrote:

I've shared my project TParr - VirtualMachineInterpreter here: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter

And, I've created a short YouTube video showing it in operation here: https://youtu.be/74GH0Qr9VA0

This is an effort to fix the links in my original message re making a virtual machine in Snap!

Video of Prof Parr: https://www.youtube.com/watch?v=74GH0Qr9VA0&feature=youtu.be

Snap! shared project: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter

My YouTube video of the project running (computing 5!): https://youtu.be/74GH0Qr9VA0

Last edited by doloop (April 14, 2017 19:38:05)

Jonathan50
Scratcher
1000+ posts

Snap! user discussion

The links won't work until you become a Scratcher (right now you are a New Scratcher).

ae2d2bcb-e9e3-4f9c-a847-290d71bd8bfd 222ec087-6694-42cf-8c41-064e9066f004
Gabriel2900
Scratcher
100+ posts

Snap! user discussion

doloop wrote:

doloop wrote:

I've shared my project TParr - VirtualMachineInterpreter here: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter

And, I've created a short YouTube video showing it in operation here: https://youtu.be/74GH0Qr9VA0

This is an effort to fix the links in my original message re making a virtual machine in Snap!

Video of Prof Parr: https://www.youtube.com/watch?v=74GH0Qr9VA0&feature=youtu.be

Snap! shared project: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter

My YouTube video of the project running (computing 5!): https://youtu.be/74GH0Qr9VA0

doloop wrote:

doloop wrote:

I've shared my project TParr - VirtualMachineInterpreter here: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter

And, I've created a short YouTube video showing it in operation here: https://youtu.be/74GH0Qr9VA0

This is an effort to fix the links in my original message re making a virtual machine in Snap!

Video of Prof Parr: https://www.youtube.com/watch?v=74GH0Qr9VA0&feature=youtu.be
Snap! shared project: http://snap.berkeley.edu/snapsource/snap.html#present:Username=doloop&ProjectName=TParr%20-%20VirtualMachineInterpeter
My YouTube video of the project running (computing 5!): https://youtu.be/74GH0Qr9VA0
See. It works for me.
gbuk
Scratcher
5 posts

Snap! user discussion

I am relatively new to Snap! and especially its internals.
(I did some work, about 7 years ago, for the Open University using Scratch 1.4. However, I haven't looked at Snap! internals until now.)

I have some questions:
Q1) How should I add more symbols to the Block Editor's “Edit Label Fragment”?
“Edit Label Fragment” has a drop-down list of small symbols; for example from square and pointRight to robot and magnifyingGlass.

I have found code in blocks.js which draws those symbols onto a canvas. I want to avoid changing blocks.js if possible.

Is there a mechanism which enables new symbols to be added without changing blocks.js? For example, is there an ‘API’ to add new symbols to “Edit Label Fragment” drop-down list? Or is there a better way?

Ideally my code which modifies that list would be encapsulated in an imported project that the user could choose. Is that practical?

Q2) Is there a way to make the “Edit Label Fragment” drop-down symbol list scroll?
When the browser window is reduced (to allow me to see other windows) the list is too tall to fit the window. Some symbols are beyond the window and, AFAICT, they can't be selected. This may be a bug, or my lack of familiarity with Snap!

Last edited by gbuk (April 15, 2017 15:08:27)

bharvey
Scratcher
1000+ posts

Snap! user discussion

gbuk wrote:

Q1) How should I add more symbols to the Block Editor's “Edit Label Fragment”?
I'm afraid the only way is the way you already know about. But if you're going to do that, make it so the user can type something like $#03bb to get a lambda (or whatever Unicode character), instead of just adding specific drawn glyphs to the menu.
Ideally my code which modifies that list would be encapsulated in an imported project that the user could choose. Is that practical?
You can use the Javascript Function block (in Operators) to create new primitives that you code in js.

Q2) Is there a way to make the “Edit Label Fragment” drop-down symbol list scroll?
Not if you mean an easy way. MenuMorphs aren't scrollable. You could invent a ScrollableMenuMorph that inherits from MenuMorph and includes code you steal from ScrollableFrameMorph. That might be worth doing, although I'd be inclined instead to use an existing feature, namely submenus, so you could have a submenu “arrows” with all the arrow shapes, etc.

bharvey
Scratcher
1000+ posts

Snap! user discussion

frodewin wrote:

Is there a list with Snap URLs or another way to get to the game?
I passed this on to Dan Garcia. There isn't an easy-to-use list of them, but they're probably all accessible somehow or other. I could try bugging him again (but see the note above about permissions).

gbuk
Scratcher
5 posts

Snap! user discussion

bharvey wrote:

gbuk wrote:

Q1) How should I add more symbols to the Block Editor's “Edit Label Fragment”?
I'm afraid the only way is the way you already know about. But if you're going to do that, make it so the user can type something like $#03bb to get a lambda (or whatever Unicode character), instead of just adding specific drawn glyphs to the menu.
The symbols (likely) won't be any standard unicode character glyph.
Are you saying we should use Unicode ‘Private-Use Characters’ (http://www.unicode.org/faq/private_use.html) for our symbols?
If that is what you mean, does Snap! recommend a range of Unicode ‘Private-Use Characters’ code-points?

bharvey wrote:

gbuk wrote:

Ideally … code … would be encapsulated in an imported project …
You can use the Javascript Function block (in Operators) to create new primitives that you code in js.
Okay. So we can avoid messing with the Snap! code base. Lovely!

bharvey wrote:

gbuk wrote:

Q2) Is there a way to make the “Edit Label Fragment” drop-down symbol list scroll?
Not if you mean an easy way. MenuMorphs aren't scrollable. You could invent a ScrollableMenuMorph that inherits from MenuMorph and includes code you steal from ScrollableFrameMorph. That might be worth doing, although I'd be inclined instead to use an existing feature, namely submenus, so you could have a submenu “arrows” with all the arrow shapes, etc.
Okay, I think a submenu might be clearer anyway. Though if they were Unicode code points, I could imagine there's less need to modify this menu anyway.

Is there a recommendation on how to add custom glyphs (referenced as Unicode code points, maybe ‘Private-use’) to Snap! ?

Thank you very much for your thorough and clear answers. They are very helpful.

Last edited by gbuk (April 16, 2017 10:48:03)

bharvey
Scratcher
1000+ posts

Snap! user discussion

gbuk wrote:

Are you saying we should use Unicode ‘Private-Use Characters’ (http://www.unicode.org/faq/private_use.html) for our symbols?
Oh, no, I just meant that lots of times I want glyphs that are in Unicode (mostly it's lambda that I want) and I'm trying to hijack your issue. But you can paste the actual character into the title text field, so I don't really need it.

Okay, I think a submenu might be clearer anyway. Though if they were Unicode code points, I could imagine there's less need to modify this menu anyway.
Hot news: Jens has implemented scrollable menus in GP and plans to add them to Snap! too.

frodewin
Scratcher
500+ posts

Snap! user discussion

bharvey wrote:

frodewin wrote:

Is there a list with Snap URLs or another way to get to the game?
I passed this on to Dan Garcia. There isn't an easy-to-use list of them, but they're probably all accessible somehow or other. I could try bugging him again (but see the note above about permissions).

I saw your explanation above, thanks. It actually triggered a discussion in our (German-speaking) online Scratch Club today. Not that we came up with a solution to the problem. I understand - but don't agree with - the teachers' concerns and on the other hand such a limitation on finding and accessing best practice projects really hinders the progress in the community.

Why don't you try out some of my projects. I love to get feedback!
Click on the images to try them out.


You can find my best projects here or drop by my profile and say hi there!
ironmannn
Scratcher
100+ posts

Snap! user discussion

So I found an interesting bug in Snap!.

I figured out how to access this within a function when using the javascript reporter and run block. that runs fine an all with one function, here's an example of such code that runs without a problem.

this.line = function (x1, y1, x2, y2)
{
this.up();
this.gotoXY(x1, y1);
this.down();
this.gotoXY(x2, y2);
this.up();
};

this.line(0, 0, 100, 100);

however, when I add another function to the code, even if I don't call the first function I created within that new one. Snap soon freezes after executing the code and I have to reload the page in order to get any further work done.

this.line = function (x1, y1, x2, y2)
{
this.up();
this.gotoXY(x1, y1);
this.down();
this.gotoXY(x2, y2);
this.up();
};

this.genTile = function (size, degrees)
{
this.clear();

//Define coordinate table arrays.
coX = [];
coY = [];

// Convert degrees to radians.
radians = degrees * (3.1415 / 180);

// calculate boundaries of starting quadrilateral.
aX = -1 * size / 2;
aY = size / 2;
bX = size / 2;
bY = -1 * size / 2;

// Generate our coordinates.
clockY = 0;
while (clockY < size)
{
coY.push(aY - clockY);
coY.push(aY - clockY);

coX.push(aX);
coX.push(bX);
clockY = clockY + 1;
};

// Test code to ensure the coordinates are being generated correctly.
/*clockC = 0;
while (clockC < coX.length - 1)
{
this.line(aX, coY[clockC], bX, coY[clockC]);
clockC = clockC + 2;
};*/
};

this.genTile(45, 0);

I'm not entirely sure what's going on, but I thought it would be worth reporting here.


EDIT: Okay, it seems to be something else. I tried to remove the function and just write it's code within the main function, the code executes sucessfully but it's still crashing the moment the code has executed.

this.genTile = function (size, degrees)
{
this.clear();

//Define coordinate table arrays.
coX = [];
coY = [];

// Convert degrees to radians.
radians = degrees * (3.1415 / 180);

// calculate boundaries of starting quadrilateral.
aX = -1 * size / 2;
aY = size / 2;
bX = size / 2;
bY = -1 * size / 2;

clockY = 0;
while (clockY < size)
{
coY.push(aY - clockY);
coY.push(aY - clockY);

coX.push(aX);
coX.push(bX);
clockY = clockY + 1;
};

clockC = 0;
while (clockC < coX.length)
{
this.up();
this.gotoXY(coX[clockC], coY[clockC]);
this.down();
this.gotoXY(coX[clockC + 1], coY[clockC + 1]);
clockC = clockC + 1;
};
};

this.genTile(45, 0);

Last edited by ironmannn (April 27, 2017 15:21:31)


when green flag clicked
do really complicated thing
bharvey
Scratcher
1000+ posts

Snap! user discussion

ironmannn wrote:

So I found an interesting bug in Snap!.
When I edit your code to put a var at the beginning of genTile so that you're not making a zillion global variables, it works. I presume that one of the names you used is a global variable in Snap! but I didn't bother working out which one. Sorry, not a Snap! bug.

joefarebrother
Scratcher
500+ posts

Snap! user discussion

IIRC from the last time I looked at the Snap! code, it's radians, which is a global function in Snap!. Assigning it to something that isn't a function breaks a lot of stuff.

(Opening the web console would have probably revealed this as you'd probably see errors like “radians is not a function” being reported from snap!'s code)


And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
ironmannn
Scratcher
100+ posts

Snap! user discussion

bharvey wrote:

ironmannn wrote:

So I found an interesting bug in Snap!.
When I edit your code to put a var at the beginning of genTile so that you're not making a zillion global variables, it works. I presume that one of the names you used is a global variable in Snap! but I didn't bother working out which one. Sorry, not a Snap! bug.

Interesting, I'll have to take a look into that. Thanks for the help.

when green flag clicked
do really complicated thing

Powered by DjangoBB

Standard | Mobile