I have a panning picture that is being scaled and "pulled" across the display. The problem is I'm making this game for different resolutions/aspect ratios, I need to to tell the computer to stop scrolling when it gets to the edge of the bitmap.
I can't count how long it's been panning because for widescreen it pans less and for 4:3 it pans more.
The picture is 1240x360 an scrolling from right to left
at 1024x768 it moves the bitmap -1456 pixels (the 1240x360 bitmap is scaled to 2645x768)
at 1280x720 it moves the bitmap -1200 pixels (the 1240x360 bitmap is scaled to 2480x720)
to 1920x1024 it moved the bitmap -1800 pixels (The 1240x360 bitmap is scaled to 3527x1024)
I got these numbers via trial and error and I don't want to make a table for all possible resolutions and I'm not sure how to calculate this manually
As a sneaky way I thought I would solve this problem was put a special color pixel in the lower right corner my bitmap and then test the lower right corner of the display when it comes up. The problem is that al_get_pixel() crashes when the bitmap being read is the display.
Because I can't math well, I don't know how to calculate the offset for any given resolution. (I'm sure there is a way, but I don't know how to begin)
here's a bit of psudocode
Is there a better way?
========== SUPER EDIT ===============
I just wanted to give some closure on this so I'm not this guy --> https://xkcd.com/979/
I Mathed my way out of it. Here is how you do it if to do the same thing. I also made all the sizes generic so you can scroll any sized bitmap (longer than the display) to any resolution