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

#1 2010-10-23 20:30:03

bdn7
Scratcher
Registered: 2010-07-10
Posts: 100+

Scrolling with velocity.

I am making a new game called Post War and it's a scroller. I want the scrolling to speed up when you hold the arrow key and slow down over time instead of stopping immediately when you release it. Can anyone help me?


http://i.imgur.com/Q7PiV.png
That's right. My text is BLUE.

Offline

 

#2 2010-10-23 20:43:54

HD123
Scratcher
Registered: 2009-12-05
Posts: 500+

Re: Scrolling with velocity.

bdn7 wrote:

I am making a new game called Post War and it's a scroller. I want the scrolling to speed up when you hold the arrow key and slow down over time instead of stopping immediately when you release it. Can anyone help me?

[blocks]
<when green flag clicked>
<set{ xvel }to( 0
<forever>
<if><key[ right arrow ]pressed?>
<change{ xvel }by( 0.5
<end>
<if><key[ left arrow ]pressed?>
<change{ xvel }by( -0.5
<end>
<end>

<when green flag clicked>
<forever>
<change{ scrollx }by( (( -1 <*> <{ xvel }> ))
<set{ xvel }to( (( <{ xvel }> <*> 0.95 ))
<end>
[/blocks]

Last edited by HD123 (2010-10-23 20:44:11)


~~HD123~~
Treat others as you want to be treated. |  big_smile  | http://i.imgur.com/OaNrY.gif | http://blocks.scratchr.org/libstatus.php?user=HD123&amp;online=http://lemonfanatic.webs.com/ONLINE.png&amp;offline=http://lemonfanatic.webs.com/OFFLINE.png

Offline

 

Board footer