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

#1 2012-12-05 17:32:02

Portalmaker
Scratcher
Registered: 2012-10-21
Posts: 76

New Motion Script

I found a new script to move a sprite:

when gf clicked
set [x v] to [0]
set [y v] to [0]
forever
 go to x: (x) y:(y)
end
when [up arrow v] key pressed      
change [y v] by [10]
when [down arrow v] key pressed
change [y v] by [-10]
when [right arrow v] key pressed
change [x v] by [10] 
when [left arrow v] key pressed
change [x v] by [-10]
link

Last edited by Portalmaker (2012-12-07 17:31:02)


-_meow_

Offline

 

#2 2012-12-07 23:04:50

roflcopter526
Scratcher
Registered: 2012-01-27
Posts: 88

Re: New Motion Script

that would be a pretty jumpy script. And why the variables?

Offline

 

#3 2012-12-08 09:27:53

Portalmaker
Scratcher
Registered: 2012-10-21
Posts: 76

Re: New Motion Script

Oh the variables control the x/y position of the sprite.


-_meow_

Offline

 

#4 2012-12-08 13:07:40

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

Re: New Motion Script

This is a very good script but I am not sure if this is the right forum for it. I think it suits Help With Scripts better.

Offline

 

#5 2012-12-14 23:39:43

lalala3
Scratcher
Registered: 2008-10-03
Posts: 100+

Re: New Motion Script

The variables are pointless, and those hat blocks cause very choppy movement. It creates better performance if you do this:

when gf clicked
go to x: (0) y: (0)
forever
if <key [up arrow v] pressed?>
change y by (10)
end
if <key [down arrow v] pressed?>
change y by (-10)
end
if <key [right arrow v] pressed?>
change x by (10)
end
if <key [left arrow v] pressed?>
change x by (-10)
end
end


http://img515.imageshack.us/img515/9374/signature2nt.png

Offline

 

#6 2012-12-15 09:59:17

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

Re: New Motion Script

lalala3 wrote:

The variables are pointless, and those hat blocks cause very choppy movement. It creates better performance if you do this:

when gf clicked
go to x: (0) y: (0)
forever
if <key [up arrow v] pressed?>
change y by (10)
end
if <key [down arrow v] pressed?>
change y by (-10)
end
if <key [right arrow v] pressed?>
change x by (10)
end
if <key [left arrow v] pressed?>
change x by (-10)
end
end

Completely right.


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

Offline

 

Board footer