Parallax Scrolling -- I've got it!

⌘-R in Chief
Posts: 1,247
Joined: 2002.05
Post: #1
Well, I figured out parallax scrolling on my own. I figured it couldn't be too hard, so I thought about it for a second, and played with it for a while and I figured it out.

Here's the two lines of code (per layer) that it requires:

LayerOffset = DeltaX * ((LayerWidth - ViewWidth)/(ForegroundLayerWidth-(ViewWidth*2))
DrawPicture LayerPicture, LayerOffset, 0

Where ViewWidth is the width of the animation area (i.e. if you wer e full screen, ViewWidth would be the screen width), and DeltaX is the number of pixels that you're scrolling.

One thing I did notice is that in my current example project, the Foreground scrolling rate isn't equal to 1, it's actually equal to 1.3 which is kind of odd. I know that it makes sense mathematically using the code above, but I wonder what I would need to change to get it equal to 1 instead. If you have any ideas on that, could you let me know?



One other question, where did the word Parallax come from? It obviously sounds like a combination of parallel axis, which kind of makes senses, but is that really where it came from?
Quote this message in a reply
ededed
Unregistered
 
Post: #2
Well on the subject of flaunting your own intelligence. To test if you have cliked on an odd or even isometric tile of size 64*31

sin(((x-32)*pi)/64)>cos(((y-64)*pi)/32)

It works on my computer I have rigerously tested it I worked that out myself too!!!
Quote this message in a reply
Member
Posts: 204
Joined: 2002.09
Post: #3
Quote:Originally posted by FreakSoftware
One other question, where did the word Parallax come from? It obviously sounds like a combination of parallel axis, which kind of makes senses, but is that really where it came from?


From what I know, the word parallax came from astronomers who use the parallax of stars in order to determine their distance from earth. You can do this because of the properties of a triangle and by using basic geometry to solve for the correct side of the triangle.

Cheers,
Rocco
Quote this message in a reply
⌘-R in Chief
Posts: 1,247
Joined: 2002.05
Post: #4
Quote:Originally posted by KittyMac
From what I know, the word parallax came from astronomers who use the parallax of stars in order to determine their distance from earth. You can do this because of the properties of a triangle and by using basic geometry to solve for the correct side of the triangle.


Now that makes perfect sense. Thanks
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #5
I'm not really sure on the full meaning of the word, but here's my two cents; para- is a prefix for "beyond" or "more than" or even "after". -lax is a stem for a lot of words meaning "wider", "wide", "widening", "extending" and suchlike.

Thus, parallax would mean something around the lines of "beyond the wide", which is quite appropriate for something used to measure stars. Smile

All in Latin of course. Smile
Quote this message in a reply
Post Reply