screen.py 360 B

12345678910111213141516
  1. import pygame.display
  2. # get screen resolution
  3. pygame.display.init()
  4. _info = pygame.display.Info()
  5. _w, _h = screen_size = _info.current_w, _info.current_h
  6. pygame.display.quit()
  7. def pixel_coords(x, y):
  8. """
  9. Translate coordinates (x, y) with 0 <= x <= 1 and 0 <= y <= 1 to pixel
  10. coordinates using the screen size.
  11. """
  12. return _w * x, _h * y