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

#1 2012-11-10 21:52:43

Nekro
Scratcher
Registered: 2012-11-10
Posts: 8

Help with velocity

How do you make velocity? When I do it, I thought it was working, but it kept moving back in the same place. Here's how I'm doing it:

when gf clicked
forever
 if <key [right arrow v] pressed?>
  change [velocity x v]  by [1]
 end
 if <key [right arrow v] pressed?>
  change [velocity x v] by [-1]
 end
 set x to ([velocity x])
 change [velocity x v] by (([velocity x] * [0.9]))
I'm not a good scriptor online


Scratch 2.0 Will come out on January 28th 2012!-Terraria rocks!
http://i50.tinypic.com/208880l.jpg

Offline

 

#2 2012-11-10 22:00:06

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Help with velocity

Nekro wrote:

How do you make velocity? When I do it, I thought it was working, but it kept moving back in the same place. Here's how I'm doing it:

when gf clicked
forever
 if <key [right arrow v] pressed?>
  change [velocity x v]  by [1]
 end
 if <key [right arrow v] pressed?>
  change [velocity x v] by [-1]
 end
 set x to (velocity x)
 change [velocity x v] by ((velocity x) * [0.9])
I'm not a good scriptor online

Fixed.

Anyway, the problem I see is that you're setting your x position to x velocity, when you should be changing it by your x velocity. Fix that and you should be good.

I hope that this helps!

Last edited by ErnieParke (2012-11-10 22:00:33)


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2013-02-10 00:26:16

WIlliam7777
Scratcher
Registered: 2012-07-21
Posts: 41

Re: Help with velocity

Here is the script:


when gf clicked

if <key [right arrow v] pressed?> 

change [x velocity v] by (1)

end

if <key [left arrow v] pressed?> 

change [x velocity v] by (-1)

end

if <touching color [#000008]?> 

set [y velocity v] to [0.1]

if <key [up arrow v] pressed?> 

set [y velocity v] to [15]

end

end

set [x velocity v] to ((x velocity) * (0.9))

change x by (x velocity)

change y by (y velocity)

change [y velocity v] by (-1)

Last edited by WIlliam7777 (2013-02-10 00:26:57)

Offline

 

#4 2013-02-10 00:29:15

WIlliam7777
Scratcher
Registered: 2012-07-21
Posts: 41

Re: Help with velocity

Nekro wrote:

How do you make velocity? When I do it, I thought it was working, but it kept moving back in the same place. Here's how I'm doing it:

when gf clicked
forever
 if <key [right arrow v] pressed?>
  change [velocity x v]  by [1]
 end
 if <key [right arrow v] pressed?>
  change [velocity x v] by [-1]
 end
 set x to ([velocity x])
 change [velocity x v] by (([velocity x] * [0.9]))
I'm not a good scriptor online

The set x block should changed to change x block.

The script should like this:


when gf clicked
if <key [right arrow v] pressed?> 

change [x velocity v] by (1)

end

if <key [left arrow v] pressed?> 

change [x velocity v] by (-1)

end

if <touching color [#000008]?> 

set [y velocity v] to [0.1]

if <key [up arrow v] pressed?> 

set [y velocity v] to [15]

end

end

set [x velocity v] to ((x velocity) * (0.9))

change x by (x velocity)

change y by (y velocity)

change [y velocity v] by (-1)

Last edited by WIlliam7777 (2013-02-10 00:30:08)

Offline

 

#5 2013-02-10 03:14:04

Sqervay
New Scratcher
Registered: 2012-10-28
Posts: 52

Re: Help with velocity

^^ But this in a forever-loop

Offline

 

Board footer