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

#1 2012-12-02 10:49:18

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Scrolling and moving in direction

I have a script

when green flag clicked
set [scrollX v] to [0]
set [scrollY v] to [0]
set [turningVel v] to [0]
set [velocity v] to [0]
forever
 go to front
 if <key [left arrow v] pressed?>
  change [turningVel v] by (-1)
 end
 if <key [right arrow v] pressed?>
  change [turningVel v] by (1)
 end
 if <key [up arrow v] pressed?>
  change [velocity v] by (1)
 end
 if <<key [down arrow v] pressed?> and <[0] < (velocity)>>   
  change [velocity v] by (-1)
 end
 if <[0] > (velocity)>    
  set [velocity v] to [0]    
 end  
 set [turningVel v] to ((turningVel) * (0.98))           
 set [velocity v] to ((velocity) * (0.98))  
Is there a way to incorporate the scrolling with the move steps block?  Can someone give me a script for it?

Last edited by Firedrake969 (2012-12-02 11:03:39)


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#2 2012-12-02 11:02:24

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: Scrolling and moving in direction

Firedrake969 wrote:

when green flag clicked
set [scrollX v] to [0]
set [scrollY v] to [0]
set [turningVel v] to [0]
set [velocity v] to [0]
forever
 go to front
 if <key [left arrow v] pressed?>
  change [turningVel v] by (-1)
 end
 if <key [right arrow v] pressed?>
  change [turningVel v] by (1)
 end
 if <key [up arrow v] pressed?>
  change [velocity v] by (1)
 end
 if <<key [down arrow v] pressed?> and <[0] < (velocity)>>   
  change [velocity v] by (-1)
 end
 if <[0] > (velocity)>    
  set [velocity v] to [0]    
 end  
 set [turningVel v] to ((turningVel) * (0.98))           
 set [velocity v] to ((velocity) * (0.98))    

Offline

 

#3 2012-12-03 12:17:03

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Scrolling and moving in direction

bump


Alt of Firedrake969.

Offline

 

#4 2012-12-03 16:46:42

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Scrolling and moving in direction

Just to make sure, do you have ScrollX and ScrollY?

Last edited by ErnieParke (2012-12-03 19:56:42)


http://i46.tinypic.com/35ismmc.png

Offline

 

#5 2012-12-03 19:13:18

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Scrolling and moving in direction

ErnieParke wrote:

Just to make sure, do have ScrollX and ScrollY?

Yes.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#6 2012-12-03 19:57:26

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Scrolling and moving in direction

Firedrake969 wrote:

ErnieParke wrote:

Just to make sure, do have ScrollX and ScrollY?

Yes.

And when do you need this script by?


http://i46.tinypic.com/35ismmc.png

Offline

 

#7 2012-12-04 12:34:03

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Scrolling and moving in direction

ErnieParke wrote:

Firedrake969 wrote:

ErnieParke wrote:

Just to make sure, do have ScrollX and ScrollY?

Yes.

And when do you need this script by?

Anytime.


Alt of Firedrake969.

Offline

 

#8 2012-12-04 15:04:30

30-1
Scratcher
Registered: 2012-08-08
Posts: 100+

Re: Scrolling and moving in direction

I'm not sure if you can incorporate it with the move steps block. But you can do something else:

when gf clicked
set [direction v] to [0]
forever
 change [direction v] by (turningVel)
 change [scrollX v] by ((([sin v] of ((direction)*(1)))*(velocity))*(-1))
 change [scrollY v] by ((([cos v] of ((direction)*(1)))*(velocity))*(-1))
If you don't find that helpful you could look at these projects: here and here.
Hope this helps  big_smile

Last edited by 30-1 (2012-12-06 08:12:24)


http://i.imgur.com/ocOya7x.gif
I. Text I Based I Games I

Offline

 

#9 2012-12-04 18:49:44

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Scrolling and moving in direction

Wow thanks!


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#10 2012-12-06 08:17:46

30-1
Scratcher
Registered: 2012-08-08
Posts: 100+

Re: Scrolling and moving in direction

Firedrake969 wrote:

Wow thanks!

Your'e welcome.
I fixed the script because you wanted scrolling


http://i.imgur.com/ocOya7x.gif
I. Text I Based I Games I

Offline

 

Board footer