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

#1 2010-08-08 21:56:01

soupoftomato
Scratcher
Registered: 2009-07-18
Posts: 1000+

Making A Sprite Move At A Constant Rate

I have a sprite and I need it to move to the mouse whenever the mouse is clicked. I know I have to use glide, but how do I get a constant speed. (Setting the seconds makes it zippity fast on long distances and sluggishly slow on short ones)

I have a variable named speed placed in the glide block where the (seconds) is, so what equation do I need to use to set, "speed"?


I'm glad to think that the community will always be kind and helpful, the language will always be a fun and easy way to be introduced into programming, the motto will always be: Imagine, Program, Share - Nomolos

Offline

 

#2 2010-08-08 21:57:29

militarydudes
Scratcher
Registered: 2008-09-12
Posts: 1000+

Re: Making A Sprite Move At A Constant Rate

Just change the amount of seconds in the glide block. The higher the number, the slower it goes.


__m. .m__ KILROY WAS HERE
        U

Offline

 

#3 2010-08-08 21:59:38

soupoftomato
Scratcher
Registered: 2009-07-18
Posts: 1000+

Re: Making A Sprite Move At A Constant Rate

militarydudes wrote:

The higher the number, the slower it goes.

I know, but that makes it seem super fast on long distances and super slow on short ones. I want a constant speed so that nothing feels strange.

If it took me 5 seconds to go a mile in a car, it would be speeding, if it took me five seconds to go a foot, it would be pulled over for going two slow. That's sort of like what would happen to my sprite.

I swear I explained this in the topic post, but I explained more clear in case you needed it.


I'm glad to think that the community will always be kind and helpful, the language will always be a fun and easy way to be introduced into programming, the motto will always be: Imagine, Program, Share - Nomolos

Offline

 

#4 2010-08-08 23:03:39

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Making A Sprite Move At A Constant Rate

Use the distance to mousepointer and divide by 100


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#5 2010-08-09 00:47:12

KaltSoldat
Scratcher
Registered: 2010-07-09
Posts: 100+

Re: Making A Sprite Move At A Constant Rate

Ok, I think I understand what you mean, in the sprite that you want to move towards your mouse add [blocks]<when green flag clicked>[/blocks][blocks]<forever>[/blocks][blocks]<point towards( mouse-pointer[/blocks]

And then add [blocks]<when green flag clicked>[/blocks][blocks]<forever>[/blocks][blocks]<wait until>[/blocks][blocks]<mouse down?>[/blocks][blocks]<repeat until>[/blocks][blocks]<touching[ mouse-pointer[/blocks][blocks]<move( how fast you want it to go )steps>[/blocks]

Offline

 

#6 2010-08-09 01:18:24

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Making A Sprite Move At A Constant Rate

AtomicBawm3 wrote:

Use the distance to mousepointer and divide by 100

That's awesome! It works  big_smile


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

Board footer