How to disable vertical / horizontal mouse movement in pygame?
<p>I want to prevent an object from moving vertically on the surface when moving the mouse around while horizontal movements will still be allowed. </p>

<p>How do I do that?</p>

<p>I have managed to let the object move around freely using:</p>

<pre><code>            if event.type == pygame.MOUSEMOTION:
            x, y = event.pos
</code></pre>

<p>But don't know how disable y from responding and allow only x to move.</p>

<p>Any advice will be appreciated.</p>

<p>BTW - I have read similar questions but nothing was related specifically to this issue.</p>

<p>I don't remember much of Pygame, so I might be missing something, but it looks kinda obvious:</p>

<pre><code>if event.type == pygame.MOUSEMOTION:
    x = event.pos[0]
</code></pre>

python python-3.x pygame