   collision detection + control
  hi, im currently having problem to apply my collision detection in 2D. so here is my design:when user enter an input (up down left right) the newX and newY is updated. each up down left right button is presented by boolean, set true when pressed, set false when released. its kinda simple and generic i think.then i try to apply a simple collision detection. i use grid to check the position of the object. so if an object is in grid (4, 5), i keep its index in an array with index (4,5). when it try to move eg: to (4, 6), i first check if there is a collision occured. if not move, if yes (currently) don't move. The problem is when i try to press up and left at the same time. the object should move to (5, 6), newX and newY is set to (5, 6) and check for collision). however, if you can imagine, this movement cant be done since there is object in (5, 5) and to move to (5, 6), the object must pass grid (5, 5). So what I expect is the object to move to the right first, and then move forward (instead of having a diagonal movement). I think my problem is in my control design and its connection to the collision detection algorithm. Currently i set the newX and newY for all object, then check if there is a collision, if not, set x and y as newX and newY. but it seem not working. anyone have an idea how should i do this?   
  But the object could move to (4,6) first then move over to (5,6), avoiding the collision.  So the move is still legitimate, but I think your rules for moving diagonally are the real issue.  If you allow diagonal moves, you are actually moving quite a bit farther distance than if you only allow vertical and horizontal moves.  To correct the issue, you could allow diagonal moves only if there isn't any objects vertically or horizontally in the target grid point.For example, with your current system if there were objects at 5,5 and 4,6 you would still be able to make it through.  If you restricted diagonal moves to times when there are no obstructions horizontally or vertically then you eliminate the problem altogether.   