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

#1 2012-07-22 10:16:08

Angelflower0
Scratcher
Registered: 2012-07-20
Posts: 8

help me with script

how do you move a animal with arrow keys?

Offline

 

#2 2012-07-22 10:20:58

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: help me with script

Ok Angelflower0, this is the script. 

when gf clicked
forever
if <key [up arrow v] pressed?>
point in direction (0 v)
move (number of steps you want) steps
end
if <key [down arrow v] pressed?>
point in direction (180 v)
move (number of steps you want) steps
end
if <key [right arrow v] pressed?>
point in direction (90 v)
move (number of steps you want) steps
end
if <key [left arrow v] pressed?>
point in direction (-90 v)
move (number of steps you want) steps
end

Last edited by Firedrake969 (2012-07-22 10:21:55)


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#3 2012-07-22 11:07:16

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: help me with script

Or you could use this:

when gf clicked
forever
if <key [left arrow v] pressed?>
change x by (-10) //This number will determine how fast the sprite moves.
end
if <key [right arrow v] pressed?>
change x by (10)
end
if <key [up arrow v] pressed?>
change y by (10) 
end
if <key [down arrow v] pressed?>
change y by (-10) 
end
end

Last edited by JH1010 (2012-07-22 11:08:03)

Offline

 

#4 2012-07-22 11:10:11

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: help me with script

JH1010 wrote:

Or you could use this:

when gf clicked
forever
if <key [left arrow v] pressed?>
change x by (-10) //This number will determine how fast the sprite moves.
end
if <key [right arrow v] pressed?>
change x by (10)
end
if <key [up arrow v] pressed?>
change y by (10) 
end
if <key [down arrow v] pressed?>
change y by (-10) 
end
end

Angelflower, if you want it pointed in a certain direction, use my script.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#5 2012-07-22 11:29:42

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Re: help me with script

Or:

when gf clicked
forever
 if <key [up arrow v] pressed?>
 move (how fast you want to move) steps
 end
 if <key [down arrow v] pressed?>
 move (how fast you want to move backward [note:  be sure that this number is negative.]) steps
 end
 if <key [right arrow v] pressed?>
 turn cw (how fast you want to turn right) degrees
 end
 if <key [left arrow v] pressed?>
 turn ccw (how fast you want to turn left) degrees
 end
this will move in the direction you are pointing, and you use the left and right arrow keys to turn.


http://i47.tinypic.com/2iaa73k.png

Offline

 

Board footer