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

#1 2010-05-06 23:17:51

frozenveinz
Scratcher
Registered: 2010-04-24
Posts: 28

X and Y Scrolling?

Hey guys. I'm working on a space game, and i need to be able to scroll both left/right and up/down. I've got the left right figured out, (it's very simple) but once i try to add the same scripts for y, (substituting 480 for 360 of course) the "terrain" sprites end up being diagonal to each other, like so:
Does anyone know what im doing wrong?




                            .................
                            .................
                            .................
             .............
             .............
             .............
.............
.............
.............


P.S My code for each sprite is

[blocks]
<when green flag clicked>
<forever>
<set x to( (( <{ ScrollX }> <+> (( 480 <*> 0 )) ))    (i add 1 for each terrain, blahblahblah)
<set y to(  (( <{ ScrollY }> <+> (( 360 <*> 0 )) ))

And yah......


http://i970.photobucket.com/albums/ae184/frozenveinz/RickRoll.gif

Offline

 

#2 2010-05-06 23:34:10

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: X and Y Scrolling?

I know what you are doing, your scripts look like this I bet

//for terrain 1

greenflag
forever
set x to (( {   ScrollX  } + ((   480  *   0  )) ))      (i add 1 for each terrain, blahblahblah)
set y to (( {   ScrollY  } + ((   360  *   0  )) ))


//for terrain 2

greenflag
forever
set x to (( {   ScrollX  } + ((   480  *   1  )) ))      (i add 1 for each terrain, blahblahblah)
set y to (( {   ScrollY  } + ((   360  *   1  )) ))


This is not how to make a proper grid which is what you want.

For this grid, the number for the scrollX is on the left and the number for scrollY is on the right for each set of values

(0,2) (1,2) (2,2) (3,2)
(0,1) (1,1) (2,1) (3,1)
(0,0) (1,0) (2,0) (3,0)

                                                                           _
Looking at this grid, since your sprites were like _  -

Your numbers were like this:
for the first sprite, 0 for scrollX and 0 for scrollY
for the second sprite, 1 for scrollX and 1 for scrollY
for the third sprite 2 for scrollX and 2 for scrollY

Now see how those numbers line up with the grid I typed

the number beside scrollX controls the far to the side the sprite is and the number beside scrollY controls how far up the sprite is.

Here is an example of this http://scratch.mit.edu/projects/archmage/100982

Last edited by archmage (2010-05-06 23:39:28)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2010-05-06 23:49:24

frozenveinz
Scratcher
Registered: 2010-04-24
Posts: 28

Re: X and Y Scrolling?

OOHHHH i see what you mean... But how would i fix it? I've been trying.. Do i do it like
scrollX=480*2
scrollY=360*1
is that it??
i think im wrong tho

Last edited by frozenveinz (2010-05-06 23:50:19)


http://i970.photobucket.com/albums/ae184/frozenveinz/RickRoll.gif

Offline

 

#4 2010-05-07 00:04:43

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: X and Y Scrolling?

Try looking at the code in the example project.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#5 2010-05-07 03:28:06

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: X and Y Scrolling?

I do 480*(a number of where it is eg the first is 0 the second it 1)-{SCROLLX})


You can now reach me on Twitter @johnnydean1_

Offline

 

#6 2010-05-07 08:04:36

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: X and Y Scrolling?

I'm just so happen to be making a verticalscroller, and it appears you have the right idea..

What I did was

Forever(acutally  the block is "repeat until")
goto x: (scrollx + 480 * 0) y: (scrolly + 360 * 0) (ground level, first platform)
next block would be 480 * 1 and 360 *1(if you were making a tiled thing like you mentioned.)


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#7 2010-05-07 13:21:48

maail
Scratcher
Registered: 2009-04-02
Posts: 1000+

Re: X and Y Scrolling?

wow i still don't get it!


http://i.imgur.com/uH8sS.png

Offline

 

#8 2010-05-07 16:49:13

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: X and Y Scrolling?

You could look at my project x^2, but it has literally like 40 sprites 'cause of the bullets, so it might take a while to download.


nXIII

Offline

 

#9 2010-05-22 22:02:55

PupStar
Scratcher
Registered: 2010-05-18
Posts: 1

Re: X and Y Scrolling?

HELP ME WITH SCROLLING... The terrain randomly moves!!! I know you do scrollx and change x by scrollx x terrain or something

Offline

 

#10 2010-05-22 22:19:42

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

Re: X and Y Scrolling?

PupStar wrote:

HELP ME WITH SCROLLING... The terrain randomly moves!!! I know you do scrollx and change x by scrollx x terrain or something

It's actually set x to scrollx*terrain, which should sort out your issues for the most part.

Hope that helps!

Offline

 

#11 2010-06-15 07:45:22

mopper2
Scratcher
Registered: 2010-05-31
Posts: 33

Re: X and Y Scrolling?

i need help too

<when green flag clicked>
<change{ scroll y }by(
<forever if>((<{ scroll y }> ((  <*>  )) <+>  ))
somthing like that


MOPPER2

Offline

 

#12 2010-10-24 12:39:25

masterpie124
Scratcher
Registered: 2010-01-19
Posts: 2

Re: X and Y Scrolling?

I need help D= i trying to make a game that scrolls x and y with more than one sprites. plz respond.

Offline

 

#13 2010-10-24 12:41:25

TornFusion
Scratcher
Registered: 2010-09-03
Posts: 1000+

Re: X and Y Scrolling?

??

Offline

 

#14 2010-10-24 12:44:34

TornFusion
Scratcher
Registered: 2010-09-03
Posts: 1000+

Re: X and Y Scrolling?

Sorry for spamming but I just need to check something...

http://scratchhtmlviewer.net23.net/image.php?project=1372300&amp;amp;user=tornfusion

Offline

 

#15 2010-10-25 11:47:55

meofcourse
Scratcher
Registered: 2010-10-22
Posts: 6

Re: X and Y Scrolling?

based on pokemon gaming i have created a 4 directional scrolling screen but i have a bed sprite made of three sprites (definetly dont meen costumes) and when i walk upwards they either move seperate or make the whole thing look terrible how do i get them to move of screen thank you

please explain simply i was good at maths until they threw letters in so x and y axi can be a bit frustrating
thanks again  smile

Offline

 

#16 2011-04-01 16:46:19

TheBoBGuy
New Scratcher
Registered: 2011-03-28
Posts: 1

Re: X and Y Scrolling?

I don't understand how they work though  hmm

Offline

 

#17 2011-08-30 04:11:32

Palacecastle
Scratcher
Registered: 2011-05-16
Posts: 1

Re: X and Y Scrolling?

http://<move(  )steps><move(  )steps><move(  )steps>scratch.mit.edu/forums/viewtopic.php?id=35277#req_message

Offline

 

#18 2011-08-30 09:10:11

XKRISTISX
Scratcher
Registered: 2011-01-09
Posts: 4

Re: X and Y Scrolling?

<change{  }by( http://scratch.mit.edu/forums/viewtopic.php?id=35277#req_message

Offline

 

#19 2011-08-30 11:30:06

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: X and Y Scrolling?

This sounds like it should be in All About Scratch.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#20 2011-08-30 17:09:32

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: X and Y Scrolling?

this should be in all about scratch


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#21 2011-11-21 13:13:42

adam_spillers
New Scratcher
Registered: 2011-11-21
Posts: 2

Re: X and Y Scrolling?

try this <when green flag clicked><set x to( ((  <+>   480 <*>0  ))
then for the next one do <when green flag clicked><set x to( ((  <+>   480 <*>1  ))
and so on  smile  hop it works for u

Offline

 

#22 2011-11-21 13:41:40

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: X and Y Scrolling?

adam_spillers wrote:

try this <when green flag clicked><set x to( ((  <+>   480 <*>0  ))
then for the next one do <when green flag clicked><set x to( ((  <+>   480 <*>1  ))
and so on  smile  hop it works for u

You need to put a forever block around it, else it will only go to that position when the project is started, and won't move from then on.  smile


Why

Offline

 

Board footer