# Parallax techniques

This topic is 3300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm not sure if this would be the same as parallax scrolling but I can't find anything that could help. I'm trying to make a 2D game where you move into the world, so as you move forwards the smaller objects at the top of the screen get bigger and lower as they get closer. I have a simple prototype to try and get the scale right with just a floor that is moving down. My floor image is tiled and its X scale is set based on it's Y position. 0 is scale 1, anything higher is smaller and lower is higher for example -600 is 0.25 and 600 is 4. While this is correct at those points for everything inbetween the tiles don't match up and the edges of the floor that should be moving through the bottom corners of the screen, move up the sides and then down again. I hope that I have explained that properly but if anyone could point me in the right direction I would be grateful. Thanks.

##### Share on other sites
Can you add some screenshots and a sketch of what you are trying to get as a result?

##### Share on other sites
Hopefully this image will explain what I am trying to do better.
I want tile an image like it vertically so that as the player continues moving forwards, everything else in the world moves down and gets bigger.

The main problem that I am having is that my tiles don't line up correctly or scale correctly as they move.

##### Share on other sites
Quote:
 Original post by Android07While this is correct at those points for everything inbetween the tiles don't match up

That's to be expected.

Quote:
 and the edges of the floor that should be moving through the bottom corners of the screen, move up the sides and then down again.

What do the edges of the tiles have to do with the edges of the floor? Your tile edges are presumably horizontal and vertical, while the floor needs to be defined by diagonal lines.

Have you considered an approach other than tiling for the background?

##### Share on other sites
Android,

It is a matter or correctly adjusting the 'Z-value' for each vertex. You don't need to adjust the X-scale as this will appear to happen automatically.

If you have square tiles, the upper vertices of the bottom row must match up with the lower vertices or the second row, and so on.
// this should make a single columnfloat fStartDepth = ... // The Z value for the lowest verticesfloat fTileDepth = ...  // The change in depth over one tilefor (int y = 0; y < toprow; y++){     glVertex3f(  0.0f,  0.0f + y, fStartDepth -  y      * fTileDepth);     glVertex3f(  1.0f,  0.0f + y, fStartDepth -  y      * fTileDepth);     glVertex3f(  0.0f,  1.0f + y, fStartDepth - (y + 1) * fTileDepth);     glVertex3f(  1.0f,  1.0f + y, fStartDepth - (y + 1) * fTileDepth);       }
You now just need to take into account tiling in the x direction and adjust the values to suit your application.

Hope this helps,
M

##### Share on other sites
Thanks for that, I was hoping to be able to achieve the effect in 2D, similar to F-Zero.

##### Share on other sites

This topic is 3300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628735
• Total Posts
2984449

• 25
• 11
• 10
• 16
• 14