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

#1 2008-11-11 16:36:02

dazman
Scratcher
Registered: 2008-02-21
Posts: 26

Velocity

Hi,
I was having a problem the other day. I was trying to make a script that would make the sprite fall faster when they've been in the air longer. or go faster when the arrow key is held down for a long period of time.
Please Help!!!


http://scratch.mit.edu/static/icons/buddy/82338_med.png

Offline

 

#2 2008-11-11 16:48:49

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Velocity

For horizontal movement:

when (green flag) clicked
forever
   if <key [left arrow] pressed>
     change xvelocity by -0.5
   if <key [right arrow] pressed>
     change xvelocity by 0.5
   change x by xvelocity

Hope that helps  big_smile

Last edited by coolstuff (2008-11-11 16:52:06)

Offline

 

#3 2008-11-11 17:02:34

sonick637
Scratcher
Registered: 2008-08-09
Posts: 21

Re: Velocity

there should be a pre-downloaded sprite called the gravity ball. Just edit the scripts a little and you have a velocity'd character. (P.S. Click on the banner at the bottom of this post.)


http://i.imgur.com/6F09o.jpg

Offline

 

#4 2008-11-11 17:52:20

dingdong
Scratcher
Registered: 2007-08-09
Posts: 1000+

Re: Velocity

there are plenty of velocities, here are the 2 most important:

moving technique:
forever
if <key[left arrow]pressed?>
   change Xspeed by (-0.2)
if <key[right arrow]pressed?>
   change Xspeed by (0.2)
if < <not<key[right arrow]pressed?> > or <not<key[left arrow]pressed?> > >
   set Xspeed to ( (Xspeed) * (0.9) )
change X by Xspeed

jumping technique:
forever
if <key[up arrow]pressed?>
   set Yspeed to (5)
   change Y by (Yspeed)
   repeat until <touching color [ground color]>
      change Y by Yspeed
      change Yspeed by (-0.2)
   set Yspeed to (0)


http://img851.imageshack.us/img851/2829/superanbanner.png
click the image for my music

Offline

 

Board footer