I've got my collissions up and running ( up to a point ). In 1 situation if my moving object ( ball ) hits a stationary object everything is cool, 1 collision detected and behave as expected. Problem begins when an object moves towards other and second moves towards first as presented in situation 2. Then I get 2 collisions and I would like to get rid off such inconvenience. For learning purposes im using 1 pixel per frame movement for both objects so it is easier to understand. Collision checking is very simple and its basically something like this:
if( Rect.intersecting other Rect ){ then move away by one pixel }
in gameloop.
Since I like pictures i've drawn it, so here's pic:
My question what's the solution? And maybe what are advantages and disadvantages if there are multiple solutions?
And the second question is kinda related, I guess ... When we get into higher velocities, let's say ball is moving twice as fast ( 2 pixels per frame!
) then similar situation happens, except when we get 10 times speed we miss collision completely. It's called tunelling/ghosting but I need more details about how to solve it. Do I need prediction of movement, or checking ( sweep ) after? How to get actual point of collision?