Discuss Scratch

kingofcool4
Scratcher
29 posts

help with sprite movement code

my sprites movement script is currently this:


define movex (keyx)

change by ((0.95) * (key x (this is a my block input idk if it will show as pink or orange))
set to ((0.95) * (x speed))
change x by (x speed)

also this:


define movey (y value)

change by ((0.95) * (key y (this is a my block input idk if it will show as pink or orange))
set to ((0.95) * (y speed))
change y by (y speed)


this are some other scripts used to move:
whenclickedforevermoveykey up arrowpressed?-key down arrowpressed?

whenclickedforevermovexkey right arrowpressed?-key left arrowpressed?


How do I make the character move faster?

Last edited by kingofcool4 (Feb. 2, 2025 22:41:31)

kittyje1
Scratcher
83 posts

help with sprite movement code

You could try putting a multiply block around the input in the movex and movey blocks. But it's kind of hard to read for me. Do you think you can put everything in blocks please? Thank you.
kingofcool4
Scratcher
29 posts

help with sprite movement code

do you mean like put the subtract operator in the multipying one or put the key pressed sensor in a multiplier
kingofcool4
Scratcher
29 posts

help with sprite movement code

kittyje1 wrote:

You could try putting a multiply block around the input in the movex and movey blocks. But it's kind of hard to read for me. Do you think you can put everything in blocks please? Thank you.
Scratcher
25 posts
help with sprite movement code
do you mean like put the subtract operator in the multipying one or put the key pressed sensor in a multiplier
kingofcool4
Scratcher
29 posts

help with sprite movement code

kittyje1 wrote:

You could try putting a multiply block around the input in the movex and movey blocks. But it's kind of hard to read for me. Do you think you can put everything in blocks please? Thank you.
I could attach an image of the script
kittyje1
Scratcher
83 posts

help with sprite movement code

kingofcool4 wrote:

…snip…
do you mean like put the subtract operator in the multipying one or put the key pressed sensor in a multiplier


Like this:
moveykeyup arrowpressed?-keydown arrowpressed?*yourspeed
kingofcool4
Scratcher
29 posts

help with sprite movement code

kittyje1 wrote:

kingofcool4 wrote:

…snip…
do you mean like put the subtract operator in the multipying one or put the key pressed sensor in a multiplier


Like this:
moveykeyup arrowpressed?-keydown arrowpressed?*yourspeed


thanks! it actually works!

Powered by DjangoBB