-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.py
More file actions
31 lines (22 loc) · 945 Bytes
/
window.py
File metadata and controls
31 lines (22 loc) · 945 Bytes
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
import pygame
class Window:
def __init__(self) -> None:
self.width: int | None = None
self.height: int | None = None
self.name: str | None = None
self._window = None
def init(self, width: int, height: int, name: str | None = None) -> None:
self.width = width
self.height = height
self.name = name
self._window = pygame.display.set_mode((width, height))
if name is not None:
pygame.display.set_caption(name)
def flip(self) -> None:
pygame.display.flip()
def draw_rect(self, color: tuple[int, int, int], rect: pygame.rect.Rect, width: int = 0, border_radius: int = 0) -> None:
pygame.draw.rect(self._window, color, rect, width, border_radius)
def blit(self, *args, **kwargs) -> None:
self._window.blit(*args, **kwargs)
def fill(self, *args, **kwargs) -> None:
self._window.fill(*args, **kwargs)