Introducing Snape!

Snape! is a block library that I have created. You can find a version of it here.

Snape! uses maths at a great extent and I plan to add more blocks to it. I might turn it into an extension with a few other features which would have more things other than just blocks.

Interested in a code critique? (You're allowed to say no.)

Always!

Here is an example project-

Okay, let's start there... I don't think that's what "parity" means, at least not in computer science. It's not whether the number is odd or even; it's wheter the number of 1 bits in the binary representation of the number is odd or even. So for example, 1000, 0100, 0010, and 0001 all have one 1 bit, and are therefore odd parity. 1110, 1101, 1011, and 0111 all have three 1 bits, and so they're also odd parity. But 0000, 1100, 1010, 1001, 0110, 0101, 0011, and 1111 have even parity.

The reason this is a useful idea is that by adding one extra bit ("the parity bit") that isn't part of the value but is set so that the parity including that bit is always odd, you can check the parity of every number retrieved from memory and discover an error in any single bit, which will make the parity even. (Such errors can happen for all sorts of reasons, including a cosmic ray striking the computer!)

Parity is the simplest form of error correction. It detects a single error, but doesn't tell you which bit is wrong. With a few more bits and a more complicated algorithm, you can tell which bit is wrong, and therefore correct the error; if two bits are wrong, you can detect but not correct that situation.


Your BOUNCE block does reflex reflection, which is what the special paint they use on highway signs does: it reflects light right back in the same direction it came from, so that your headlights reflect off the sign into your eyes. The primitive IF ON EDGE BOUNCE does specular reflection, which is what mirrors do: the reflected light follows a path such that the angle between the mirror and the light is the same on the way in and on the way out, but in the opposite orientation.


Of course your DO WHEN STOP SIGN CLICKED would have to be a hat block, not a command block. But, you may not realize, we provide that in the WHEN I AM hat block, one of whose options is STOPPED. And there's no predicate like the one you propose because it could never possibly report True -- if the stop sign has been clicked, all the scripts are stopped! (The one started by WHEN I AM STOPPED has the restriction that it can only run for one display cycle. Its purpose is to allow the program to issue stop commands to hardware such as robots.)


PREVIOUS COSTUME is good, except for one small detail: if the current costume number is 1, it should switch to costume LENGTH OF (MY COSTUMES) rather than to costume 0.

In the various DRAW blocks, my preference (this is really just a stylistic preference) is not to include PEN DOWN and PEN UP in shape blocks. There are exceptions, but in general I prefer to leave open the question of whether the pen is down when drawing the shape. (Why wouldn't you want it down? Maybe you are trying to get the sprite to the position and heading it would have after drawing a whatever, but not actually draw it.) And if you do want to put the pen down, I would do it this way:
untitled script pic
so that if the pen was already down you don't lose that information.

Hmm...the concept is mathematical not a CS one (intentionally).

I agree that is not so good.

Why not to the turtle costume? Is it a special concept?

They were not meant to be there. I did not notice I did not delete them!

I do not understand it.

Typically when you use NEXT COSTUME (and therefore would use PREVIOUS COSTUME) it's because you've imported a set of related costumes:
abby a abby b abby c abby d
and you want to rotate through them. So, it's not that the turtle costume is impossible to use that way, just that it's generally not part of the set of costumes you're using.

Costume

Fixed that block. Try it yourself-

Oh, I understand it now. But how are you going to write text with my draw blocks?

Right, it'd require modifying them. But the example served its purpose of getting you to understand what I meant. :~)

I see but I am assuming that means I do not have to modify my block.
By the way, could my stop sign hack convince you in believing that it was possible to run scripts after clicking the stop sign?

When I clicked the link it said there was no such project.

That probably was the dumbest work I ever did, sorry. You should be able to access it now.
I am surprised to hear you cannot access unshared projects.

You shouldn't be surprised; private projects are private!

That's a very clever bit of coding. It almost works; I have to click the stop sign twice before the second script is allowed to run. (This is a deliberate restriction on the generic-when block to prevent just the sort of thing you've done, which could make unstoppable programs.)

I saw the square red button for the first time in Snap! when testing the block. Scratch does not have that so it is possible to run scripts without the user's permission on Scratch.

Wait, what? It is? Wow. I did not know that.

(Also, not gonna lie, when I first saw this was called Snape I instantly thought of Harry Potter XD)

I am a Potterhead but not big enough to name it following Prof. Severus Snape's name.

This is the 1.0 version of Snape! . This version of Snape! updates blocks per Brian's suggestions and adds new blocks; the new blocks include but are not limited to "stop sign clicked?" and "enter key pressed?" predicate blocks. 0.1.0 will still be available to download. // cc @bh

It's my own fault for reading Harry Potter and the Half-Blood Prince nonstop during quarantine XD