Discuss Scratch

FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]

I have a project and there is a glitch that i cannot fix, but you can make a new block. Can you make a glide block with steps? Here is how I imagine the block:

Glide _ seconds _ Steps

If you add this in scratch, thank you.
Botcho_Otkho
Scratcher
1000+ posts

New Coding Block [glide block with steps]

How would this work?
-ShadowOfTheFuture-
Scratcher
1000+ posts

New Coding Block [glide block with steps]

Does this block mean, keep moving a fixed amount of steps per frame for (number) seconds? Or would it instead take (number) seconds to move the fixed number of steps?
FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]

Number seonds
FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]

TO move the number of steps
Botcho_Otkho
Scratcher
1000+ posts

New Coding Block [glide block with steps]

FF76YT wrote:

Number seonds

FF76YT wrote:

TO move the number of steps
That still doesn't explain…
python_megapixel
Scratcher
500+ posts

New Coding Block [glide block with steps]

Do you mean like
move (10) steps

but with gliding?
FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]

yes
wWSunPandaWw
Scratcher
1000+ posts

New Coding Block [glide block with steps]

FF76YT wrote:

yes
glide (10) secs to x: (0) y: (0)
Why isn't this suffice? You either want to glide or move steps, there's no way to do two at once.

Last edited by wWSunPandaWw (April 27, 2018 14:42:00)

Botcho_Otkho
Scratcher
1000+ posts

New Coding Block [glide block with steps]

FF76YT wrote:

yes
Please, use the quote button next time that you're answering to someone.
FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]

wWSunPandaWw wrote:

FF76YT wrote:

yes
glide (10) secs to x: (0) y: (0)
Why isn't this suffice? You either want to glide or move steps, there's no way to do two at once.

I want to glide a certain amount of steps
_nix
Scratcher
1000+ posts

New Coding Block [glide block with steps]

For now, I know this is a really complicated block, but this might work for you:

glide (10) secs to x: ((x position) + ((50) * ([cos v] of (direction)))) y: ((y position) + ((50) * ([sin v] of (direction))))

You'll need to replace those 50s with the distance you want to go, and the 10 with the time (of course). Also, you won't find the “cos” and “sin” blocks in the block list; you need to take out an “abs” block instead (it's at the very bottom of the Operators list), then click the dropdown and change it to “cos” or “sin”.

Here's what the block looks like in another version of Scratch with easier-to-see blocks, if you're having trouble putting it together:



Have you heard of custom blocks? You could use a custom block to make this a bit simpler:

define glide (time) secs (dist) steps
glide (time) secs to x: ((x position) + ((dist) * ([cos v] of (direction)))) y: ((y position) + ((dist) * ([sin v] of (direction))))

Then you just use the “glide secs steps” block the same way you would any other block:

glide (10) secs (50) steps :: custom

(Edit: fill in [scratchblocks] tag after I forgot to, oops!)

Last edited by _nix (April 27, 2018 23:08:15)

Botcho_Otkho
Scratcher
1000+ posts

New Coding Block [glide block with steps]

DanFish wrote:

repeat (10)
move (10) steps
end
This should work
It doesn't, because you have to glide with steps to those cordinates, and will require a block like
point to x (10) y (10)::motion
FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]

Thank you for your help all
FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]

_nix wrote:

For now, I know this is a really complicated block, but this might work for you:


Then you just use the “glide secs steps” block the same way you would any other block:

Can you put a new post with the edit

Last edited by FF76YT (April 29, 2018 20:22:27)

_nix
Scratcher
1000+ posts

New Coding Block [glide block with steps]

FF76YT wrote:

_nix wrote:

For now, I know this is a really complicated block, but this might work for you:


Then you just use the “glide secs steps” block the same way you would any other block:

Can you put a new post with the edit
Oops, I'm sorry I phrased my sentence badly. I meant that I, myself, had fixed a typo in my post. So you don't need to worry about it; my complete post is already there
FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]


_nix wrote:

FF76YT wrote:

_nix wrote:

For now, I know this is a really complicated block, but this might work for you:


Then you just use the “glide secs steps” block the same way you would any other block:

Can you put a new post with the edit
Oops, I'm sorry I phrased my sentence badly. I meant that I, myself, had fixed a typo in my post. So you don't need to worry about it; my complete post is already there
It doesn't work
Can you help?
_nix
Scratcher
1000+ posts

New Coding Block [glide block with steps]

FF76YT wrote:

It doesn't work
Can you help?
Okay! Try this project: https://scratch.mit.edu/projects/219579017/#editor

You can drag the big “define glide” script into your backpack, then put it into your own project. Here is a video showing you how to use the backpack: https://www.youtube.com/watch?v=1T4pOTHlHfM

(That video shows you how to use the backpack with sprites, but it works the same way for scripts.)

Once you have the “define glide” script in your own project, you can find the block in the “More Blocks” list, which is at the very end of the category list:


FF76YT
Scratcher
13 posts

New Coding Block [glide block with steps]

Thanks!
One more thing, can you add this block into scratch so I don't always have to type this in?
_nix
Scratcher
1000+ posts

New Coding Block [glide block with steps]

FF76YT wrote:

Thanks!
One more thing, can you add this block into scratch so I don't always have to type this in?
There's not really a way to do that, unfortunately. But once you have the “define” script in your backpack, you can always drag it out whenever you want.

Powered by DjangoBB