1

I've spent the past week creating a raycasting algorithm in Python using Pygame, and it ran perfectly fine before I added textures to the walls. But now when running in windowed mode the mouse input does not work properly, and as a solution I made it so that the q and e keys do the job of turning the camera instead. My code can be found here, but to run it in windowed mode you'll have to change these lines:

WIDTH    = 1360
HEIGHT   = 768

SCREEN   = pygame.display.set_mode((WIDTH, HEIGHT), pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.FULLSCREEN)

To these lines:

WIDTH    = 680 
HEIGHT   = 384

SCREEN   = pygame.display.set_mode((WIDTH, HEIGHT))

So that the entire screen can be seen in windowed mode.

So why is it that the mouse input doesn't work properly, and what can I do to fix it?

Community
  • 1
  • 1
George Willcox
  • 677
  • 12
  • 30
  • check with [`pygame.mouse.get_focused()`](https://www.pygame.org/docs/ref/mouse.html#pygame.mouse.get_focused) to see if you have focus or not. I suspect that's the issue. – TemporalWolf Apr 05 '17 at 18:43
  • If this is the issue, what can I do to resolve it? – George Willcox Apr 05 '17 at 18:46
  • Have you tried clicking on the window? That's usually how you give it focus. – TemporalWolf Apr 05 '17 at 18:47
  • No this wouldn't be the issue, the window is definitely selected, and it worked fine before I added textures. I just tested this by adding `print(pygame.mouse.get_focused())` after the line `pygame.mouse.set_pos((WIDTH / 2, HEIGHT / 2))` And `1` was returned. However, this offered a noticeable improvement, and removing the line returns it back to how it was before – George Willcox Apr 05 '17 at 18:53
  • Have you tried fullscreen with textures? – TemporalWolf Apr 05 '17 at 18:55
  • @TemporalWolf Yes I have, and the mouse input works fine then. But unless I call `print(pygame.mouse.get_focused())` it doesn't work properly in windowed mode, and I have to use the q and e keys to turn the camera. – George Willcox Apr 06 '17 at 17:05

0 Answers0