-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquit_.py
More file actions
40 lines (31 loc) · 1.12 KB
/
quit_.py
File metadata and controls
40 lines (31 loc) · 1.12 KB
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
38
39
40
import state_manager
import pygame
import os
import locations
class Quit(state_manager.State):
def __init__(self) -> None:
super().__init__()
self._tick = 3000
self._skip = False
self._surface = pygame.image.load(locations.image('quit.png')).convert_alpha()
def render(self) -> None:
self.screen.blit(self._surface, (0, 0))
pygame.display.flip()
def input(self) -> None:
for event in pygame.event.get():
if event.type == pygame.QUIT:
self._skip = True
elif event.type == pygame.KEYDOWN:
self._skip = True
elif event.type == pygame.MOUSEBUTTONDOWN:
l, m, r = pygame.mouse.get_pressed()
if l == 1:
self._skip = True
def update(self, delta: int, fps: float) -> None:
self._tick -= delta
if self._skip or self._tick <= 0:
self.state_manager.terminate_main_loop()
def leave(self, next_: state_manager.StateType) -> None:
pass
def enter(self, prev_: state_manager.StateType) -> None:
self._tick = 3000