I am trying to make an algorithm that reads in basic map data and basically scales it so it will display objects properly on another platform. It only deals with X,Y co-ordinates and its a side scrolling game.
All it really has is simple obstacles that you avoid. But they are drawn at a different size on the other platform. So origionaly their drawn at 40x40 pixels but on the target their drawn at 50x50. The Y value is no problem because its a simple conversion:
If Y = 0 then Y = 500 on the target (you have to reverse the Y but not the X so dont worry)
If Y = 40 then Y = 450 on the target. Basically 500-(40*1.25)
But their is the problem, you cant simply multiply the X value as its constantly increasing as the level plays. The height will always be in the same range but not the length. And the distance between the blocks is important.
A basic example would be
Original map data::
object(1000, 0);
object(1162, 40);
object(1352, 40);
object(1542, 40);
object(1704, 80);
object(1866, 120);
object(1906, 120);
object(1946, 120);
Target map data::
object(1000, 500);
object(1215, 450);
object(1475, 450);
object(1735, 450);
object(1950, 400);
object(2165, 350);
object(2215, 350);
object(2265, 350);
Now I've tried a number of things, looping through the data trying to shift each object one by one depending on the position of the others, but I cant some to get it to work.
All it really has is simple obstacles that you avoid. But they are drawn at a different size on the other platform. So origionaly their drawn at 40x40 pixels but on the target their drawn at 50x50. The Y value is no problem because its a simple conversion:
If Y = 0 then Y = 500 on the target (you have to reverse the Y but not the X so dont worry)
If Y = 40 then Y = 450 on the target. Basically 500-(40*1.25)
But their is the problem, you cant simply multiply the X value as its constantly increasing as the level plays. The height will always be in the same range but not the length. And the distance between the blocks is important.
A basic example would be
Original map data::
object(1000, 0);
object(1162, 40);
object(1352, 40);
object(1542, 40);
object(1704, 80);
object(1866, 120);
object(1906, 120);
object(1946, 120);
Target map data::
object(1000, 500);
object(1215, 450);
object(1475, 450);
object(1735, 450);
object(1950, 400);
object(2165, 350);
object(2215, 350);
object(2265, 350);
Now I've tried a number of things, looping through the data trying to shift each object one by one depending on the position of the others, but I cant some to get it to work.