This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-04-23 00:31:37

canadiandufus
New Scratcher
Registered: 2013-04-11
Posts: 10

How to make character move. please help

So, i am making a game were you have to find clues and move around and i am stuck on one little problem.  I can make my character move left and right by going...

When lefft arrow klicked
move -10 steps

(and)

When right arrow klicked
move 10 steps

but... i dont know how to make my character move up down and diagonal, if you could tell me how to do that it would be apreciated, especially diagonals
Thanks -canadiandufus

Offline

 

#2 2013-04-23 01:40:36

kattenelvis
Scratcher
Registered: 2013-02-06
Posts: 100+

Re: How to make character move. please help

i can help you  wink  :

when [upp arrow] clicked
change y by (10)
and -10 y (down)
you can do:

when [right key] clicked
change x by (10)
and do x-10 (left)

hope it helped  smile  because your new do stage-->backgrounds--->import and get the x-y grid for help  big_smile
hope it helped

Last edited by kattenelvis (2013-04-23 12:43:29)


http://i38.tinypic.com/35b8d4n.png

Offline

 

#3 2013-04-24 16:15:07

cauzality
New Scratcher
Registered: 2013-03-19
Posts: 44

Re: How to make character move. please help

i would do what kattenelvis said. for diagonal, do a combination. for example: up left could be

change x by [-10]
change y by [10]
at the top of the "Help with Scripts" forum page, there is a sticky topic "list of helpful topics for scripting", that would probably be of interest to you.
http://scratch.mit.edu/forums/viewtopic.php?id=88043

Offline

 

#4 2013-04-24 16:23:35

SFollis
Scratcher
Registered: 2012-03-04
Posts: 76

Re: How to make character move. please help

kattenelvis wrote:

i can help you  wink  :

when [upp arrow] clicked
change y by (10)
and -10 y (down)
you can do:

when [right key] clicked
change x by (10)
and do x-10 (left)

hope it helped  smile  because your new do stage-->backgrounds--->import and get the x-y grid for help  big_smile
hope it helped

or for more smooth moving:

when gf clicked
forever
if <key [right control key v] pressed?>
change x by (2)
when gf clicked
forever
if <key [left control key v] pressed?>
change x by (-2)
when gf clicked
forever
if <key [up control key v] pressed?>
change y by (2)
when gf clicked
forever
if <key [down control key v] pressed?>
change y by (-2)
This way, no need to do diagonal moving! it does it on it's own!  big_smile


If you want velocity, that requires more variables, like:


when gf clicked
forever
if <key [up control key v] pressed?>
change [yvel v] by (2)
when gf clicked
forever
if <key [down control key v] pressed?>
change [yvel v] by (-2)
when gf clicked
forever
if <key [right control key v] pressed?>
change [xvel v] by (2)
when gf clicked
forever
if <key [left control key v] pressed?>
change [xvel v] by (-2)
and the last script

when gf clicked
forever
set [xvel v] to ((xvel) * (0.98)
set [yvel v] to ((yvel) * (0.98)
change y by (yvel)
change x by (xvel)
And that is for smooth moving! hope this also helps  wink


http://blocks.scratchr.org/API.php?user=SFollis&amp;action=projects&amp;type=newest&amp;return=image&amp;num=1 is a picture of my project http://blocks.scratchr.org/API.php?user=SFollis&amp;action=projects&amp;type=newest&amp;return=text&amp;num=1 which has http://blocks.scratchr.org/API.php?user=SFollis&amp;action=projects&amp;type=newest&amp;return=views&amp;num=1 views

Offline

 

Board footer