Trying to create a simple bit of code that registers mouse position on click when in window and also when in fullscreen.
Currently the correct values will be returned when in windowed mode (providing cursor is over the window) however in fullscreen regardless of the mouse position I'm returned the value 800,480 (screen resolution). Here is my code:
import pygame
windowwidth = 800
windowheight = 480
pygame.init()
pygame.display.init()
screen = pygame.display.set_mode((windowwidth, windowheight))
pygame.display.flip()
running = 1
while running:
LEFT = 1
event1 = pygame.event.get()
for event in event1:
if event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT:
print(event.pos)
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_f:
pygame.display.set_mode((800,480), pygame.FULLSCREEN)
if event.key == pygame.K_g:
pygame.display.set_mode((800, 480))
else:
break
pygame.display.flip()