Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Android07
While 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?

BTW, it looks from your picture that you aren't talking about parallax but about perspective.

Share this post


Link to post
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 column
float fStartDepth = ... // The Z value for the lowest vertices
float fTileDepth = ... // The change in depth over one tile

for (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 this post


Link to post
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.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this