Discuss Scratch

MMHMMH
Scratcher
100+ posts

How do you make your sprite move up, down, left, right gracefully?

First create two variable:
(x)
(y)
(speed)
Then, do this:
when green flag clicked
set [speed v] to [however fast you want it ]
set [x v] to [0 ]
set [y v] to [0 ]
forever

change x by (x)
change y by (y)
set [x v] to ((x) * (0.9))
set [y v] to ((y) * (0.9))
if <key [right arrow v] pressed?> then

change [x v] by (speed)
end
if <key [left arrow v] pressed?> then

change [x v] by (join [-] (speed))
end
if <key [up arrow v] pressed?> then

change [y v] by (speed)
end
if <key [down arrow v] pressed?> then

change [y v] by (join [-] (speed))
end

end
That should work, but I might have missed something. Try it!
Hope this helps!

Last edited by MMHMMH (Feb. 9, 2015 16:02:27)

stevensabi
Scratcher
15 posts

How do you make your sprite move up, down, left, right gracefully?

move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
peekaboo3
Scratcher
39 posts

How do you make your sprite move up, down, left, right gracefully?

You can it's easy

forever
if <key [left arrow v] pressed?> then
change x by (-1)
end
if <key [right arrow v] pressed?> then
change x by (1)
end
if <key [up arrow v] pressed?> then
change y by (1)
end
if <key [down arrow v] pressed?> then
change y by (-1)
end

end

Last edited by peekaboo3 (May 25, 2015 17:35:26)

stevensabi
Scratcher
15 posts

How do you make your sprite move up, down, left, right gracefully?

when [left arrow] key pressed
change y by (30




say [I could really go for some bacon right now.] for (2) secs
Sigton
Scratcher
1000+ posts

How do you make your sprite move up, down, left, right gracefully?

ad1060192 wrote:

this works

forever

if <key [left arrow v] pressed?> then
point in direction [ -90 v]
change [ xvelocity v] by (-1)
end
if <key [up arrow v] pressed?> then
point in direction [ 0 v]
change [ yvelocity v] by (1)
end
end


replicate those just change the right key to +1
also the down key to -1

Fixed your scratch blocks

Sigton

Last edited by Sigton (June 7, 2015 18:35:11)

kingslayer_masacre
Scratcher
10 posts

How do you make your sprite move up, down, left, right gracefully?

Do this:


when green flag clicked
forever

set [ xvelocity] to [ ((xvelocity) * (0.95))]
set [ yvelocity] to [ ((yvelocity) * (0.95))]
change x by (xvelocity)
change y by (yvelocity)
if <key [ up arrow] pressed?> then
change [ yvelocity] by (10)
if <key [ down arrow] pressed?> then
change [ yvelocity] by (-10)
if <key [ left arrow] pressed?> then
change [ xvelocity] by (-10)
if <key [ right arrow] pressed?> then
change [ xvelocity] by (10)

end


end


end


end


end
kingslayer_masacre
Scratcher
10 posts

How do you make your sprite move up, down, left, right gracefully?

darn… I wrote it wrong.
the -if arrow key pressed- blocks aren't supposed to all be under the -if up arrow key pressed- one. Pretend that the if-then blocks are not under another if-then block
Animation_Studios
New Scratcher
3 posts

How do you make your sprite move up, down, left, right gracefully?

This Is how to make you're sprite move left
when green flag clicked
forever

if <key [ Up_Arrow] pressed?> then

end

end
Animation_Studios
New Scratcher
3 posts

How do you make your sprite move up, down, left, right gracefully?

That was not full

Animation_Studios wrote:

This Is how to make you're sprite move left
when green flag clicked
forever

if <key [ Left_Arrow] pressed?> then
set [ xVelocity] to [0 ]
repeat until <<key [ Left_Arrow] pressed?> = [False ]>
change [ xVelocity] by (-1)
change x by (xVelocity)

end


end

end
Animation_Studios
New Scratcher
3 posts

How do you make your sprite move up, down, left, right gracefully?

This is how to make you're sprite move right
when green flag clicked
forever

if <key [ Right_Arrow] pressed?> then
set [ xVelocity] to [ 0]
repeat until <<key [ Right_Arrow] pressed?> = [False ]>
change [xVelocity] by (1)
change x by (xVelocity)

end


end

end
lolotoony
Scratcher
15 posts

How do you make your sprite move up, down, left, right gracefully?

(This kinda helped me thanks!)
JJman10
Scratcher
34 posts

How do you make your sprite move up, down, left, right gracefully?

fluffykittymeowy wrote:

I want to make a project featuring that but I can't make it.

That depends. Do you want to use arrow keys or do you just want to make it move by itself?
Lyddy
Scratcher
1 post

How do you make your sprite move up, down, left, right gracefully?

lolol
s110106
New Scratcher
1 post

How do you make your sprite move up, down, left, right gracefully?

How do I make the sprite move up and down, HELP ME PLEASE!!!!
Ding_Dong_of_Duks
Scratcher
1 post

How do you make your sprite move up, down, left, right gracefully?

MiniWoofGaming wrote:

define graceful please
Where you dont need to press a button a million times or hold for a sec to walk rapidly.
subhanprogram
New Scratcher
1 post

How do you make your sprite move up, down, left, right gracefully?

when green flag clicked
forever

end
fredfish10
Scratcher
100+ posts

How do you make your sprite move up, down, left, right gracefully?

Sprite3
when clickedgo to x: 0 y: 0point in direction 240clearset Thickness to 0foreverswitch backdrop to Whiteset size to 100 %switch costume to costume2delete all of ytrcker.delete all of xtrackerdelete all of Directiondelete all of costumedelete all of sizedelete all of backdrop colourforeverset size to Thickness %if key b pressed? thenswitch backdrop to next backdropif key c pressed? thenwait 0.01 secsnext costumeif key space pressed? thenclearwait 0 secscleargo to x: 0 y: 0set I to 0foreverchange I by 1stampgo to x: item I of xtracker y: item I of ytrcker.point in direction item I of Directionswitch backdrop to item I of backdrop colourset size to item I of size %switch costume to item I of costumeif key up arrow pressed? thenmove 2 stepsadd x position to xtrackeradd y position to ytrcker.add direction to Directionadd costume # to costumeadd size to sizeadd backdrop name to backdrop colourif key left arrow pressed? thenturn 5 degreesadd x position to xtrackeradd y position to ytrcker.add direction to Directionadd costume # to costumeadd size to sizeadd backdrop name to backdrop colourif key right arrow pressed? thenturn 5 degreesadd x position to xtrackeradd y position to ytrcker.add direction to Directionadd costume # to costumeadd size to sizeadd backdrop name to backdrop colourif key down arrow pressed? thenmove -2 stepsadd x position to xtrackeradd y position to ytrcker.add direction to Directionadd costume # to costumeadd size to sizeadd backdrop name to backdrop colourif touching mouse-pointer ? and mouse down? = true thencleardelete all of xtrackerdelete all of ytrcker.delete all of Directiondelete all of costumedelete all of sizedelete all of backdrop colourstamp
njb14
Scratcher
100+ posts

How do you make your sprite move up, down, left, right gracefully?

Do:

when green flag clicked
forever

if <key [left arrow v] pressed?> then
repeat (10)
change x by (-10)
end
if <key [right arrow v] pressed?> then
repeat (10)
change x by (10)
end
if <key [down arrow v] pressed?> then
repeat (10)
change y by (-10)
end

if <key [up arrow v] pressed?> then
repeat (10)
change y by (10)
end

end

end
njb14
Scratcher
100+ posts

How do you make your sprite move up, down, left, right gracefully?

njb14 wrote:

Do:

when green flag clicked
forever

if <key [left arrow v] pressed?> then
repeat (10)
change x by (-10)
end
if <key [right arrow v] pressed?> then
repeat (10)
change x by (10)
end
if <key [down arrow v] pressed?> then
repeat (10)
change y by (-10)
end

if <key [up arrow v] pressed?> then
repeat (10)
change y by (10)
end

end

end

Oops… do that without having the “if” blocks inside each other!
Like:
when green flag clicked
forever

if <key [left arrow v] pressed?> then
repeat (10)
change x by (-10)
end
end
if <key [right arrow v] pressed?> then
repeat (10)
change x by (10)
end
end
if <key [down arrow v] pressed?> then
repeat (10)
change y by (-10)
end
end
if <key [up arrow v] pressed?> then
repeat (10)
change y by (10)
end

end
deck26
Scratcher
1000+ posts

How do you make your sprite move up, down, left, right gracefully?

This topic is getting old and should probably be considered closed.

Powered by DjangoBB