Discuss Scratch

Obsercxium
Scratcher
8 posts

How do you make a sprite slide?

I'm making a platformer and I want to make the character slide. (Like if you walk, and then you stop, the character slides?) How do you make it?
I'm bad at explaining things, so just look at this. https://scratch.mit.edu/projects/207455503/
See how the character slides when he stops walking?

when green flag clicked
say [hi, i'm obs.] for (lifespan) secs
go to [nowhere]

origins.
RokCoder
Scratcher
1000+ posts

How do you make a sprite slide?

I've made a quick project that demonstrates three styles of movement - https://scratch.mit.edu/projects/224477215/


Scratch dabbling for fun…

Bang_Mega_Xtreme
Scratcher
10 posts

How do you make a sprite slide?

Obsercxium wrote:

I'm making a platformer and I want to make the character slide. (Like if you walk, and then you stop, the character slides?) How do you make it?
I'm bad at explaining things, so just look at this. https://scratch.mit.edu/projects/207455503/
See how the character slides when he stops walking?

Make a variable and call it “Speed X” or something you will recognise. Then, follow the code below (you should modify it, this isn't the code I use in my games but it's simple enough to be understood). Basically, the code below is for simple momentum, but if you don't want the accelerating you can just set the speed.

when green flag clicked
forever
if <key [ right arrow] pressed?> then
if <(speed x) < [5 (top speed)]> then
change [ speed x] by (0.5)
change x by (speed x)
end


else
if <key [ left arrow] pressed?> then
if <(speed x) > [-5 (top speed)]> then
change [ speed x] by (-0.5)
change x by (speed x)
end


else
if <[speed x] > [0]> then
change [ speed x] by (-1)
change x by (speed x)

else
if <[speed x] < [0]> then
change [ speed x] by (1)
change x by (speed x)
end
end
end
end

I'm a little lazy to proofread the code, but I hope I didn't mistype anything. Hope this helps! If you have any doubts, feel free to ask and clarify
Happysoul05
Scratcher
100+ posts

How do you make a sprite slide?

try visiting griffpatch_tutor 's platformer tutorial.

the character slides because by pressing arrow key its velocity increases and when no key is pressed its velocity decreases slowly.without that arrow key sets the max speed and releasing it will disable moving hope you understood
PieIce
Scratcher
2 posts

How do you make a sprite slide?

move () steps
say []
when backdrop switches to [ v]
when backdrop switches to [ v]
when this sprite clicked
when [ v] key pressed
when green flag clicked
when [ v] key pressed
when backdrop switches to [ v]
when [ v] > (10)
when I receive [ v]
when I receive [ v]
when I receive [ v]
Kerbo21
Scratcher
1 post

How do you make a sprite slide?

u
btdmaster67
Scratcher
8 posts

How do you make a sprite slide?

please man! this would be legandary for the perzu!
(a game on my profile, check it out if you want to)
Jbear_
Scratcher
1000+ posts

How do you make a sprite slide?

PieIce wrote:

move () steps
say []
when backdrop switches to [ v]
when backdrop switches to [ v]
when this sprite clicked
when [ v] key pressed
when green flag clicked
when [ v] key pressed
when backdrop switches to [ v]
when [ v] > (10)
when I receive [ v]
when I receive [ v]
when I receive [ v]

Kerbo21 wrote:

u
Please don’t spam/block spam

My best project ever. Please Rate And suggest.

(Unrelated)
in memory of Celly.
Seahorsepink1
Scratcher
4 posts

How do you make a sprite slide?

how do you make a sprite slide vertically when you move it? like skating on ice effects
ProfessorUelf
Scratcher
100+ posts

How do you make a sprite slide?

Hi, in this case it is probably better to create a new topic instead of posting in a thread from 2018.

However, this is how you could do a vertically sliding sprite:

when green flag clicked
set [y velocity v] to (0)
forever
if <key [up arrow v] pressed?> then
change [y velocity v] by (1) //determines the acceleration
end
if <key [down arrow v] pressed?> then
change [y velocity v] by (-1)
end
set [y velocity v] to ((y velocity) * (0.95)) //the closer this value is to 1 the more it slides
change y by (y velocity)
end

Last edited by ProfessorUelf (April 5, 2022 22:37:01)


Seahorsepink1
Scratcher
4 posts

How do you make a sprite slide?

ty
somerandomuser1234
Scratcher
2 posts

How do you make a sprite slide?

@ProfessorUelf the variable needs to be for this sprite only or for all sprites?

Last edited by somerandomuser1234 (April 17, 2022 15:04:20)

ProfessorUelf
Scratcher
100+ posts

How do you make a sprite slide?

somerandomuser1234 wrote:

@ProfessorUelf the variable needs to be for this sprite only or for all sprites?

Generally it works in both cases. If you are moving clones, you might want to have the variable “for this sprite only”. Otherwise just keep it for all sprites, this will cause less confusion.

Cereal_Mayhem
Scratcher
59 posts

How do you make a sprite slide?

ProfessorUelf wrote:

Hi, in this case it is probably better to create a new topic instead of posting in a thread from 2018.

However, this is how you could do a vertically sliding sprite:

when green flag clicked
set [y velocity v] to (0)
forever
if <key [up arrow v] pressed?> then
change [y velocity v] by (1) //determines the acceleration
end
if <key [down arrow v] pressed?> then
change [y velocity v] by (-1)
end
set [y velocity v] to ((y velocity) * (0.95)) //the closer this value is to 1 the more it slides
change y by (y velocity)
end
When I used this is made my sprites go threw the walls
rebeccasgames
Scratcher
3 posts

How do you make a sprite slide?

point towards [ v

Powered by DjangoBB