Author Topic: Growing Image depending on Y position  (Read 959 times)

Offline diagostimo

  • Ethereal Devastator
  • ****
  • Posts: 257
  • LV: 20
    • View Profile
Growing Image depending on Y position
« on: March 24, 2013, 03:08:07 AM »
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:
Code: [Select]
                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:
Code: [Select]
                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:
(click to show/hide)
any ideas on how I would go about this?

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6585
  • LV: 407
  • Gender: Male
    • View Profile
Re: Growing Image depending on Y position
« Reply #1 on: March 24, 2013, 06:19:22 AM »
Look into Affine Tranformation. I think that's what you want.
http://www.glyphic.com/transform/