Growing Image depending on Y position

Started by diagostimo, March 23, 2013, 08:08:07 pm

Previous topic - Next topic


hey guys, I have a mini project I am working on at the moment in Java, basically what I am trying to accomplish is moving an image down the screen and scaling it depending on the Y position, the hard part is the screen is not square(640, 480), what I am doing is making a moving road Panorama, so what I am doing is drawing the road image twice, and scaling them both depending on the position, heres my code that im drawing them with at the moment:

                float scale = 0.4f;

roadFrame1.draw(0, real_y);

float width = (float) (640 * scale);;
float height = (float) (480 * scale);

float x = 320 - (width / 2);
float y = real_y - (height);

roadFrame1.draw(x, y, width, height);
then this is the update method that just ajusts real_y:

                if (real_y < 480) {
real_y += 1;
} else {
real_y = 0;

so its moving fine but I need it to scale, iv figured out that 0.4 is the exact scale for it to tile with the full sized image when placed above it, iv also tried messing around with the logic on how the scale is determined but I haven't even been able to get anything near the result I want, here is an image of the actual graphic so you have a better idea:
Spoiler: ShowHide

any ideas on how I would go about this?


Look into Affine Tranformation. I think that's what you want.