I have a set of objects i’m moving across the screen. The are going to be either 200 x 200 or 120 x 120 and will only move right or left in the x direction. I need to calculate the starting positions of the objects
This should be simple math I think, where for objects of size 120×120:
(zero is the leftmost edge of the screen)
space=10 (pixels)
object0 starts at -120 )
object1 starts at -240 + space
object2 starts at -360 + space
object3 starts at -480 + space
…
object9 starts at -1080 + space
but this isn’t working, they get more and more out of alignment the further the calculation goes. When I move them they stay in their out-of-aligned positions, as I’m adding the same amount of motion to each object.
It would also be nice also to compute the starting x positions from any given point instead of manually entering the x positions, accounting for x can be positive or negative.
Now for your example: