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

#1 2012-03-12 21:41:59

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

momentum

someone please tell how to do momentum, or post the scripts


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#2 2012-03-12 22:21:37

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

Re: momentum

Momentum is usually referred to as velocity on this site...I guess to most people they're similar enough...For momentum, instead of changing your x and y positions, you change the change of your x and y positions. This will require a minimum of one variable (for only one axis) or two variables (for both x and y).

Scripts usually look like this:

when gf clicked
set x to (start x)
set y to (start y)
set [xvel v] to (0)
set [yvel v] to (0)
forever
  if <[right arrow v] key pressed?>
    change [xvel v] by (.2)
  end
  if <[left arrow v] key pressed?>
    change [xvel v] by (-.2)
  end
  if <[up arrow v] key pressed?>
    change [yvel v] by (.2)
  end
  if <[down arrow v] key pressed?>
    change [yvel v] by (-.2)
  end
  set [xvel v] to ((xvel) * (.95))
  set [yvel v] to ((yvel) * (.95))
  change x by (xvel)
  change y by (yvel)
end
Hopefully this is the effect you were talking about.

Last edited by AtomicBawm3 (2012-03-12 22:22:28)


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

Offline

 

#3 2012-03-13 14:59:37

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: momentum

AtomicBawm3 wrote:

Momentum is usually referred to as velocity on this site...I guess to most people they're similar enough...For momentum, instead of changing your x and y positions, you change the change of your x and y positions. This will require a minimum of one variable (for only one axis) or two variables (for both x and y).

Scripts usually look like this:

when gf clicked
set x to (start x)
set y to (start y)
set [xvel v] to (0)
set [yvel v] to (0)
forever
  if <[right arrow v] key pressed?>
    change [xvel v] by (.2)
  end
  if <[left arrow v] key pressed?>
    change [xvel v] by (-.2)
  end
  if <[up arrow v] key pressed?>
    change [yvel v] by (.2)
  end
  if <[down arrow v] key pressed?>
    change [yvel v] by (-.2)
  end
  set [xvel v] to ((xvel) * (.95))
  set [yvel v] to ((yvel) * (.95))
  change x by (xvel)
  change y by (yvel)
end
Hopefully this is the effect you were talking about.

Yes! it is! Thank you!


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

Board footer