point towards x: () y: ()
move () steps towards x: () y: ()
move ()% of the way to x: () y: ()
(direction to x: () y: ())
(distance from x: () y: ())
<touching x: () y: ()> (if any part of the sprite is touching the position)
Where is the percentage in the third one?
When you get close, you get slower, like youtube(dot)com/watch?v=_EEYo3d-0Qs
The 50
in ( (50) / (100))
, I think.
Oh ok
This is not all.
set layer # to ()
(layer #)
(# of costumes)
(snapshot stage) (base64 data of the stage)
(hex of (color)) (shows the hex code)
go to [front V] layer go back (1) layers (index of (my [self V]) in (ask (my [stage V]) for ((my [other sprites V])@addInput::ring) @addInput))//Thanks, ego-lay_atman-bay. This is way better than mine. ([length V] of (my [costumes V]))
The others would be too complex for me to write off the top of my head.
Alternatively, SciSnap! has layer blocks:
About the layer blocks, there's actually a really cool thing about the (my [other sprites V])
, if you ask the stage for it, it will report all the sprites and clones in layer order. I can't figure out how to create the set layer block using this right now, but it's easy to grab the layer number, it's just (index of (my [self V]) in (ask [Stage V] for ((my [other sprites V]) @addInput) @verticalEllipsis @addInput)
That's kind of already a block, except it's exclusive to dev mode (shift + click the snap logo), and it's not a reporter.
This will save a snapshot of the stage as a costume with the specified name. You won't be able to get the base64 of the costume easily, but my question is, why specifically the base64 of the stage?
You can get this in the Colors and crayons library with this script.
I have more.
loop (sound)
stop loop (sound)
<(sound) looping?>
play (sound) from () seconds until done
start (sound) from () seconds
play (sound) from () to () seconds until done
start (sound) from () to () seconds
stop sound (sound)
pause all sounds
resume all sounds
<sound (sound) is playing?>
May I ask what this is for?
Unfortunately, most of those need javascript to use, which I don't know the scripts right now. However the loop [sound V] :: sound
can be created with just
forever { play sound (sound) until done }
(You'd have to do a lot more for the other loop blocks, this os just a basic script)
You can totally build all of these blocks using nothing but vanilla Snap!. How about you learn a little MediaComp? You can get the samples of a sound (even its channels, if it's stereo) and its sampling rate, and a little basic arithmetic...
These you can also build in plain Snap, but you'll probably want to keep track of state, so you'd want to use an OOP approach for them. How about you explore Snap's new data objects?
Really? Can you show an example?
Like, Remove the first (* seconds hz)
items from a copy of the samples, then play that?
yes, here's an example:
@ego-lay_atman-bay you're right, the second group (stop, pause, resume) cannot be done, I forgot that Snap currently only lets you stop all sounds, not on a per-sprite or per-script basis.
For some reason your block isn't working for me. If you can make it work, I have figured out the other blocks:
Good idea to use variables to keep track of state!
sigh.
I showed you an example and also told you to check for channels (mono or stereo). My example works for the built-in sounds and for recordings, because I make sure that these are always mono. This is for pedagogical reasons, so we can use sounds to introduce MediaComp with one-dimensional lists. Stereo sounds have two channels, and therefore its samples have a rank of 2.
If you want to also support stereo (or even more audio channels), here's a version for that playing those:
it relies on a helper reporter that does the actual cutting dependent on the rank of the samples:
Thanks! I'm afraid that I'm not very familiar with sounds and how to process them. I generally just try to avoid doing anything too complicated with them (just stick with one sound looping in the whole project). This has been my first endeavour to do anything with sounds in Snap! (because generally I am not making games in Snap!, but programming things like matrix algebra). Perhaps if I had read your previous post more closely (which is where you talked about the channels) I would have guessed that that might be the problem. But I didn't. Thanks again for the more versatile version of the block. Here are the updated blocks:
I probably should look at your definition more closely so that I understand it and can do something similar in the future. I will look into that later.