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

#1 2012-07-07 19:50:00

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

1 Sprite Scrolling with Velocity

So, I did something like this: 

when gf clicked
hide
forever
 clear
 if <<key [left arrow v] pressed?> and <(scrollx) < (0)>>
  change [scrollx v] by (1) 
 end
 if <<key [right arrow v] pressed?> and <(scrollx) < (960)>> 
  change [scrollx v] by (-1) 
 end
 switch to costume [costume1 v] 
 if <(scrollx) < (-480)>
 go to x: (scrollx) y: (0)
 stamp
 end
 switch to costume [costume2 v] 
 if <<(scrollx) < (0)> and <(scrollx) > (-960)>> 
 go to x: ((scrollx) + ((480) * (1))) y: (0) 
 stamp
 end
 switch to costume [costume3 v] 
 if <(scrollx) > (-480)> 
 go to x: ((scrollx) + ((480) * (2))) y: (0) 
 stamp
 end
Is there a way to do this with velocity and still keep the wall effect at -960 and 0?

Last edited by berberberber (2012-07-07 19:50:59)


http://i47.tinypic.com/2iaa73k.png

Offline

 

#2 2012-07-07 19:53:01

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: 1 Sprite Scrolling with Velocity

Yea,  instead of changing scrollx directly, just change xvel, and then have a loop that changes scrollx by xvel


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#3 2012-07-07 19:57:04

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Re: 1 Sprite Scrolling with Velocity

zammer990 wrote:

Yea,  instead of changing scrollx directly, just change xvel, and then have a loop that changes scrollx by xvel

No!  You don't get it!  I know how to do that already!  There is a wall effect at -960 and 0.  Here:  http://scratch.mit.edu/projects/berberberber/2660917  With velocities, the wall effect is out the window because of the decimals.  I need a way to do it while keeping the wall effect.

Last edited by berberberber (2012-07-07 19:59:17)


http://i47.tinypic.com/2iaa73k.png

Offline

 

#4 2012-07-07 20:01:51

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: 1 Sprite Scrolling with Velocity

I just downloaded and tried it, i don't know what you think the problem is, I just changed scrollx for xvel and toned down the numbers to 1 and -1 and it worked fine.


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#5 2012-07-07 20:02:30

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Re: 1 Sprite Scrolling with Velocity

zammer990 wrote:

I just downloaded and tried it, i don't know what you think the problem is, I just changed scrollx for xvel and toned down the numbers to 1 and -1 and it worked fine.

Okay...could you upload it?


http://i47.tinypic.com/2iaa73k.png

Offline

 

#6 2012-07-07 20:05:06

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: 1 Sprite Scrolling with Velocity

berberberber wrote:

zammer990 wrote:

I just downloaded and tried it, i don't know what you think the problem is, I just changed scrollx for xvel and toned down the numbers to 1 and -1 and it worked fine.

Okay...could you upload it?

It's not a very advanced change, but ok.
Done

Last edited by zammer990 (2012-07-07 20:05:58)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#7 2012-07-07 20:08:48

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Re: 1 Sprite Scrolling with Velocity

Like I said, the wall effect.  It's not all the way there.

Last edited by berberberber (2012-07-07 20:08:56)


http://i47.tinypic.com/2iaa73k.png

Offline

 

#8 2012-07-07 20:09:44

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: 1 Sprite Scrolling with Velocity

To fix it just add this to the end:

if <(scrollx) < (-959)>
set [scrollx v] to (959)

Last edited by zammer990 (2012-07-07 20:13:34)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#9 2012-07-07 20:28:25

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Re: 1 Sprite Scrolling with Velocity

Okay, thanks.


http://i47.tinypic.com/2iaa73k.png

Offline

 

#10 2012-07-09 09:51:02

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: 1 Sprite Scrolling with Velocity

^^ Yeah that'll work fine.

Offline

 

Board footer