-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresizable.py
37 lines (30 loc) · 1.24 KB
/
resizable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pygame, sys
mainClock = pygame.time.Clock()
from pygame.locals import *
pygame.init()
pygame.display.set_caption('game base')
monitor_size = [pygame.display.Info().current_w, pygame.display.Info().current_h]
screen = pygame.display.set_mode((500, 500), pygame.RESIZABLE)
fullscreen = False
while True:
screen.fill((0, 0, 50))
pygame.draw.rect(screen, (255, 0, 0), pygame.Rect(screen.get_width() - 5 - (screen.get_width() / 5), 50, screen.get_width() / 5, 50))
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == VIDEORESIZE:
if not fullscreen:
screen = pygame.display.set_mode((event.w, event.h), pygame.RESIZABLE)
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.quit()
sys.exit()
if event.key == K_f:
fullscreen = not fullscreen
if fullscreen:
screen = pygame.display.set_mode(monitor_size, pygame.FULLSCREEN)
else:
screen = pygame.display.set_mode((screen.get_width(), screen.get_height()), pygame.RESIZABLE)
pygame.display.update()
mainClock.tick(60)