Discuss Scratch

Mr-Mathmatical
Scratcher
95 posts

Making your sprite move smoothly

We all used to do it, and some of us still do it now. I'm talking about movement, and how to make it look smooth. Many of you have seen (or made) projects where you press and hold a key to move, but the movement is in little chunks:

when [Up Arrow] key pressed
move (10) steps

This means the sprite can move, but it kinda goes forward, wait, forward, wait.
I have a solution to this:

when green flag clicked
forever
if <key [Up Arrow] pressed?> then
move (10) steps
end
end

This means that when you press the key, it will move and not stop until you let go of the key. It makes the movement much smoother!

I hope this helped you!

Scratch on everyone!
Spontaneous08
Scratcher
100+ posts

Making your sprite move smoothly

A: This in the the wrong forum

B: Use this instead

when green flag clicked
forever
if <key [up arrow v] pressed?> then
change y by (10)

end
end
deck26
Scratcher
1000+ posts

Making your sprite move smoothly

Neither of these is particularly new though!
Mr-Mathmatical
Scratcher
95 posts

Making your sprite move smoothly

deck26 wrote:

Neither of these is particularly new though!

Yes but I've seen many projects like that and I'm just trying to let people know that this is the better way to do it.
JavierR100
Scratcher
500+ posts

Making your sprite move smoothly

Smooth moving:
when gf clicked
forever
go to x: (((x) / (2)) + ((x position) / (2))) y: (((y) / (2)) + ((y position) / (2)))
end
if you want to move it, use the variables instantead of “go to x, y” or “change x/y”:
when gf clicked
forever
if <key [left arrow v] pressed?> then
change [x v] by (-5)
end
if <key [right arrow v] pressed?> then
change [x v] by (5)
end
if <key [up arrow v] pressed?> then
change [y v] by (5)
end
if <key [down arrow v] pressed?> then
change [y v] by (-5)
end
end
Mr-Mathmatical
Scratcher
95 posts

Making your sprite move smoothly

JavierR100 wrote:

Smooth moving:
when gf clicked
forever
go to x: (((x) / (2)) + ((x position) / (2))) y: (((y) / (2)) + ((y position) / (2)))
end
if you want to move it, use the variables instantead of “go to x, y” or “change x/y”:
when gf clicked
forever
if <key [left arrow v] pressed?> then
change [x v] by (-5)
end
if <key [right arrow v] pressed?> then
change [x v] by (5)
end
if <key [up arrow v] pressed?> then
change [y v] by (5)
end
if <key [down arrow v] pressed?> then
change [y v] by (-5)
end
end
Oh thanks! I never even knew that was a thing! I'll use that instead
potatosurprise23
Scratcher
27 posts

Making your sprite move smoothly

Hello to make sprites move smoothly without stoping is
when [ v] key pressed
repeat until <not <>><key [ v] pressed?>

change y by (6)

or

change x by (6)

The number needs to be 6 to make it run smoothly

Last edited by potatosurprise23 (July 1, 2021 13:19:36)

Powered by DjangoBB