-
Notifications
You must be signed in to change notification settings - Fork 0
/
about.py
151 lines (136 loc) · 3.64 KB
/
about.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import state_manager
import background
import locations
import menu
import pygame
import consts
import quit_
SPEED = 0.1
ABOUT = [
'',
r' ____ _ ',
r' / ___|___ __| | ___ _ __ ',
r" | | / _ \ / _` |/ _ \ '__| ",
r' | |__| (_) | (_| | __/ | ',
r' \____\___/ \__,_|\___|_| ',
'',
'a game for the',
'#MetaGameJam 17-31 March 2018',
'on itch.io',
'',
'',
'~~~~~~~~~~~~',
'idea, code, graphics',
'',
'Daniel Nimmervoll',
'Lukas Singer',
'~~~~~~~~~~~~',
'',
'',
'~~~~~~~~~~~~',
'sounds',
'',
'Lukas Singer',
'',
'OpenGameArt.org',
''
'Effects:',
'Prinsu-Kun', # dead.wav
'qubodup', # insectoralien.flac
'Ogrebane', # teleport.wav
'Sudocolon', # menu_choise.mp3
''
'Song:',
'CH-AY-NA by Sprint',
'~~~~~~~~~~~~',
'',
'',
'~~~~~~~~~~~~',
'tools',
'',
'vim',
'vscode',
'gimp',
'inkscape',
'audacity',
'python',
'pyinstaller',
'pygame',
'qemu',
'~~~~~~~~~~~~',
'',
'',
'~~~~~~~~~~~~',
'special thanks',
'',
'Jana F.',
'Melanie D.',
'~~~~~~~~~~~~',
'',
'',
'~~~~~~~~~~~~',
'',
'THANKS FOR PLAYING',
'',
'~~~~~~~~~~~~',
'~~~~~~~~~~',
'~~~~~~~~',
'~~~~~~',
'~~~~',
'~~',
'']
class About(state_manager.State):
def __init__(self) -> None:
super().__init__()
self._surface = None
self._background = None
self._y = None
def _render_surface(self):
font = pygame.font.Font(locations.font('DejaVuSansMono.ttf'), 20)
top = 0
line_height = int(font.get_height() * 1.2)
self._surface = pygame.Surface((consts.SCREEN_W, line_height * (len(ABOUT) + 2)), pygame.SRCALPHA, None)
for txt in ABOUT:
surf = font.render(txt, True, (255, 255, 255), None)
self._surface.blit(surf, (self._surface.get_width() // 2 - surf.get_width() // 2, int(top)))
top += line_height
def render(self) -> None:
self._background.render(self.screen)
self.screen.blit(self._surface, (0, int(self._y)))
pygame.display.flip()
def input(self) -> None:
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.state_manager.change_state(quit_.Quit)
elif event.type == pygame.KEYDOWN:
self.state_manager.change_state(menu.Menu)
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._y -= (SPEED * delta)
if self._y < -self._surface.get_height():
self.state_manager.change_state(menu.Menu)
self._background.update(delta)
def leave(self, next_: state_manager.StateType) -> None:
pass
def enter(self, prev_: state_manager.StateType) -> None:
if self._surface is None:
self._render_surface()
# always create a new background,
# so that characters start falling from the top :-)
self._background = background.Matrix(consts.SCREEN_W, consts.SCREEN_H)
self._y = consts.SCREEN_H + 1
if __name__ == '__main__':
def init():
pygame.init()
screen = pygame.display.set_mode((consts.SCREEN_W, consts.SCREEN_H))
pygame.display.set_caption('Coder')
pygame.mouse.set_visible(0)
return screen
sm = state_manager.StateManager(init())
a = About()
sm.add_state(a)
sm.change_state(About)
sm.main_loop()