2 difficult questions

Hello.
How can I make this:
1. Take 2 points and save they coordinates in variables,
and check using this variable if the line between 2 points cross with the object (e.g. "obj1")? (so that 1 object that moves using mouse can't cross through another). And save this event in variable.
And this:
2. I have many rooms in the game. They are all 240x320. How can I count number of cirtain objects in each room?
How can I make this:
1. Take 2 points and save they coordinates in variables,
and check using this variable if the line between 2 points cross with the object (e.g. "obj1")? (so that 1 object that moves using mouse can't cross through another). And save this event in variable.
And this:
2. I have many rooms in the game. They are all 240x320. How can I count number of cirtain objects in each room?