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

#1 2011-09-26 09:52:14

rojasscratches
Scratcher
Registered: 2011-06-01
Posts: 59

velocity in scrolling

i can't figure out how to use velocity in scrolling can u help me  hmm   hmm   hmm


smile   neutral   sad   big_smile   yikes   wink   hmm   tongue   lol   mad   roll   cool  cool  Scratch Home Page  cool

Offline

 

#2 2011-09-26 14:16:59

ProgrammingAddict
New Scratcher
Registered: 2011-08-23
Posts: 22

Re: velocity in scrolling

Create two variables: X velocity, and ScrollX. Then put this script:

<when green flag clicked>
<forever>
<if><key[ right arrow ]pressed?>
<change{ X velocity }by( 2 )
<end>
<set{ X velocity }to( (( <{ X velocity }> <*> 0.97 ))
<change{ ScrollX }by( <{ X velocity }>
<end>

Obviously, you can change the if right arrow pressed bit to whatever speed you want!

Offline

 

#3 2011-09-26 16:08:25

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: velocity in scrolling

Zoid is a great example.
Download it and you can learn from the scripts.

Offline

 

#4 2011-09-26 16:43:44

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: velocity in scrolling

ProgrammingAddict wrote:

Create two variables: X velocity, and ScrollX. Then put this script:

<when green flag clicked>
<forever>
<if><key[ right arrow ]pressed?>
<change{ X velocity }by( 2 )
<end>
<set{ X velocity }to( (( <{ X velocity }> <*> 0.97 ))
<change{ ScrollX }by( <{ X velocity }>
<end>

Obviously, you can change the if right arrow pressed bit to whatever speed you want!

I think the last block should be:
[blocks]<set{ ScrollX }to( <{ X velocity }>
[/blocks] not:
  [blocks]<change{ ScrollX }by( <{ X velocity }>[/blocks].

Offline

 

#5 2011-09-27 03:11:13

ProgrammingAddict
New Scratcher
Registered: 2011-08-23
Posts: 22

Re: velocity in scrolling

Greenatic wrote:

ProgrammingAddict wrote:

Create two variables: X velocity, and ScrollX. Then put this script:

<when green flag clicked>
<forever>
<if><key[ right arrow ]pressed?>
<change{ X velocity }by( 2 )
<end>
<set{ X velocity }to( (( <{ X velocity }> <*> 0.97 ))
<change{ ScrollX }by( <{ X velocity }>
<end>

Obviously, you can change the if right arrow pressed bit to whatever speed you want!

I think the last block should be:
[blocks]<set{ ScrollX }to( <{ X velocity }>
[/blocks] not:
  [blocks]<change{ ScrollX }by( <{ X velocity }>[/blocks].

No, it's definitely change by not set to. Say the maximum speed was 6, the scrollx would never be any bigger than six with your way.

Offline

 

#6 2011-09-27 09:58:03

rojasscratches
Scratcher
Registered: 2011-06-01
Posts: 59

Re: velocity in scrolling

what about the terrain would that be any different if i add velocity  hmm


smile   neutral   sad   big_smile   yikes   wink   hmm   tongue   lol   mad   roll   cool  cool  Scratch Home Page  cool

Offline

 

Board footer