Discuss Scratch

The_Imaginarium
Scratcher
1000+ posts

Smooth walking

jdmdigital wrote:

bluedragon8633 wrote:

Use this:
foreverchangexbykeyright arrowpressed-keyleft arrowpressed

Tip- use as few hat blocks as possible.


Can you explain how that works? What are the numbers of the arrow keys for the subtraction to work? Im not a keyboard engineer but im curious.

Its the bolean isnt it. Key presses is 1 not pressed is 0.
A boolean in a number input will return 1 if true, 0 if false.

Last edited by The_Imaginarium (April 30, 2021 10:56:56)

TheDogLover796
Scratcher
1000+ posts

Smooth walking

What I do is:
whenclickedchangey velocityby-1ifkeyleft arrowpressed?thenpointindirection-90changex velocityby-1.5ifkeyright arrowpressed?thenpointindirection90changex velocityby1.5
bluedragon8633
Scratcher
1000+ posts

Smooth walking

jdmdigital wrote:

bluedragon8633 wrote:

Use this:
foreverchangexbykeyright arrowpressed-keyleft arrowpressed

Tip- use as few hat blocks as possible.


Can you explain how that works? What are the numbers of the arrow keys for the subtraction to work? Im not a keyboard engineer but im curious.

Its the bolean isnt it. Key presses is 1 not pressed is 0.
Yeah, if you're pressing the right key, you get 1. If you aren't, it's 0. If you are pressing the left key but not the right, it'll be (0-1), or -1. If neither key is pressed, it's (0-0), or no movement. You can also put a multiplication thing around it so that you move faster than just 1 pixel per frame. It's the same as this:
ifkeyrightpressedthenchangexby1ifkeyleftpressedthenchangexby-1

Powered by DjangoBB