user17097: I'm new to chess. Just played a game, my king was on d2, opponents queen was on e1, and my rook was on h1. But the program did not allowed me to capture the enemy queen with my rook, it only allowed to move my king to safety.  
Why couldn't I capture the queen with my rook?

user11629: To illustrate what was discussed in the comments above...
If we can exclude computer bugs, or other problems (there were no other pieces on g1, or f1 were there?), the situation you describe is only possible if:

the last black move was a promotion of a pawn to a queen on e1 (this pawn could have come from e2 or by capture from f2), and...
a black rook or queen was positioned on h2, g2 or f2

One example of such situation:
[FEN "2k5/8/8/8/8/8/3Kp1r1/7R b - - 0 1"]

1... e1=Q+

The technical term for this situation is Double Check and the only response to a double check is a king move as capturing one piece would still leave your king exposed to a check from the other piece.
For the example above, the only legal moves are 2. Kd3 or Kxe1. If the black queen on e1 was protected by another piece (e.g. by a black bishop from g3), the only legal move for white would be 2. Kd3.

17097: <p>I'm new to chess. Just played a game, my king was on d2, opponents queen was on e1, and my rook was on h1. But the program did not allowed me to capture the enemy queen with my rook, it only allowed to move my king to safety.  </p>

<p>Why couldn't I capture the queen with my rook?</p>
 11629: <p>To illustrate what was discussed in the comments above...</p>

<p>If we can exclude computer bugs, or other problems (there were no other pieces on g1, or f1 were there?), the situation you describe is only possible if:</p>

<ul>
<li>the last black move was a promotion of a pawn to a queen on e1 (this pawn could have come from e2 or by capture from f2), and...</li>
<li>a black rook or queen was positioned on h2, g2 or f2</li>
</ul>

<p>One example of such situation:</p>

<pre><code>[FEN "2k5/8/8/8/8/8/3Kp1r1/7R b - - 0 1"]

1... e1=Q+
</code></pre>

<p>The technical term for this situation is <a href="https://en.wikipedia.org/wiki/Double_check" rel="nofollow noreferrer">Double Check</a> and the only response to a double check is a king move as capturing one piece would still leave your king exposed to a check from the other piece.</p>

<p>For the example above, the only legal moves are 2. Kd3 or Kxe1. If the black queen on e1 was protected by another piece (e.g. by a black bishop from g3), the only legal move for white would be 2. Kd3.</p>
