Guest User

Untitled

a guest
Feb 8th, 2020
7,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. #!/usr/bin/python3.4
  2. # PYGAME 1.x ONLY
  3. # Setup Python ----------------------------------------------- #
  4. import pygame, sys
  5.  
  6. # Setup pygame/window ---------------------------------------- #
  7. mainClock = pygame.time.Clock()
  8. from pygame.locals import *
  9. pygame.init()
  10. pygame.display.set_caption('game base')
  11. monitor_size = [pygame.display.Info().current_w, pygame.display.Info().current_h]
  12. screen = pygame.display.set_mode((500, 500), pygame.RESIZABLE)
  13.  
  14. fullscreen = False
  15.  
  16. while True:
  17.  
  18.     screen.fill((0, 0, 50))
  19.  
  20.     pygame.draw.rect(screen, (255, 0, 0), pygame.Rect(screen.get_width() - 5 - (screen.get_width() / 5), 50, screen.get_width() / 5, 50))
  21.  
  22.     for event in pygame.event.get():
  23.         if event.type == QUIT:
  24.             pygame.quit()
  25.             sys.exit()
  26.         if event.type == VIDEORESIZE:
  27.             if not fullscreen:
  28.                 screen = pygame.display.set_mode((event.w, event.h), pygame.RESIZABLE)
  29.         if event.type == KEYDOWN:
  30.             if event.key == K_ESCAPE:
  31.                 pygame.quit()
  32.                 sys.exit()
  33.             if event.key == K_f:
  34.                 fullscreen = not fullscreen
  35.                 if fullscreen:
  36.                     screen = pygame.display.set_mode(monitor_size, pygame.FULLSCREEN)
  37.                 else:
  38.                     screen = pygame.display.set_mode((screen.get_width(), screen.get_height()), pygame.RESIZABLE)
  39.  
  40.     pygame.display.update()
  41.     mainClock.tick(60)
Advertisement
Add Comment
Please, Sign In to add comment