Your widgets blow my mind ( beside the Bounce Ball widget i also had a look at the Basic Movement widget ). It will take me some time to fully understand those widgets, they look pretty advanced. What i think i understand from the Bounce Ball movement is that it enters a fast-loop which slowly moves the object towards its new possition ( is this interpolation maybe? ) with collition detection along the way.
Seing that i want to use my platform movement for both Player and Enemys, im not sure a large amount of fast-loops are desireable.
I have however found a solution ( in theory ) which does not involve loops or fast-loops, which i present further down in the post
It is also very comforting to hear i shouldnt worry about this too much, though i might sometime im not about to give up just yet
I dissagree that Jacobs method solvs my problem
But before i reject it completly let me see if i have understood it correctly
Before Object ( Blue square ) moves it goes through a short loop or process where it ( Object ) is moved '1 pixle' in all four directions ( left, up, right, down ) like this
Have i missed anything or am i understanding the method correctly?
I mentioned i had some half baked ideas on how to solv this before, and i have indeed found a solution ( in theory ) of how to solv this issue ( topic ) without going through numerous loops
When my objects ( Player and Enemies ) move, they move in a line from point A to point B
Before player moves it stores its X Y coordinates in alt values.
When Player overlaps an Obstacle, it needs to check in what area ( relative to the obstacle ) it was 'previously' possitioned in ( see illustration below )
Off cource this means that when Player overlaps with an Obstacle, the program checks 8 conditions whereof 1 will trigger ( based on Players previous position )
The conditions for the center areas ( when Players previous position is in one of the center areas ) are easy because Player always moves in a straight line from A to B
On overlap + if Player previously was in 'top center' area --->
- Player collides with top of Obstacle
On overlap + if Player previously was in 'bottom center' area --->
- Player collides with bottom of Obstacle
On overlap + if Player previously was in 'left center' area --->
- Player collides with left of Obstacle
On overlap + if Player previously was in 'right center' area --->
- Player collides with right op Obstacle
The problematic part is when Players previous position is in one of the corner areas ( top left, top right, bottom left, bottom right )
I have however found a solutio for this, illustrated in an .mfa attachment at the bottom of the post ( i wont go further intoo how i figured it out, but feel free ta ask ).
When Players previous position is in one of the corner areas, i simply calculate the volume ( in pixles ) of two specific square areas ( based on Players current possition, previous possition, and corner position of Obstacle ).
I then compare the volume of those two areas to determine which is bigger.
I have attached an example file which illustrates how the volume of the two areas are calculated, for a collotion originating from the top left area of the Obstacle.
On overlap + If volume of area1 ( green area ) is greater than volume of area2 ( purple area ), its a top collition.
On overlap + If volume of area2 ( purple area ) is greater than volume of area1 ( green area ), its a left collition.
Im no expert, but I persoally belive this solution will work and is a better than a solution which move all objects ( Player and Enemies ) slowly using loops for currect collition detection ( resulting in lots of fast-loops per frame when having lots of enemies ).
My solution ( mentioned above ) calculate two values and compare them ( in 4 out of 8 possible situations ) which result in precice collition detection ( working for square objects ).