-
Notifications
You must be signed in to change notification settings - Fork 1
/
credit.py
66 lines (54 loc) · 1.65 KB
/
credit.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
from pygame import *
font.init()
def credit(text,font,color):
try: text = text.decode('utf-8')
except: pass
try: color = Color(color)
except: color = Color(*color)
clk = time.Clock()
scr = display.get_surface()
scrrect = scr.get_rect()
bg = scr.copy()
w,h = font.size(' ')
Rright = scrrect.centerx + w*3
Rleft = scrrect.centerx - w*3
foo = []
for i,l in enumerate(text.splitlines()):
a,b,c = l.partition('\\')
u = False
if a:
if a.startswith('_') and a.endswith('_'):
u = True
a = a.strip('_')
rect = Rect((0,0),font.size(a))
if b: rect.topright = Rleft,scrrect.bottom+h*i
else: rect.midtop = scrrect.centerx,scrrect.bottom+h*i
foo.append([a,rect,u])
u = False
if c:
if c.startswith('_') and c.endswith('_'):
u = True
c = c.strip('_')
rect = Rect((0,0),font.size(c))
rect.topleft = Rright,scrrect.bottom+h*i
foo.append([c,rect,u])
y = 0
while foo and not event.peek(QUIT):
event.clear()
y -= 1
for p in foo[:]:
r = p[1].move(0,y)
if r.bottom < 0:
foo.pop(0)
continue
if not isinstance(p[0],Surface):
if p[2]: font.set_underline(1)
p[0] = font.render(p[0],1,color)
font.set_underline(0)
scr.blit(p[0],r)
if r.top >= scrrect.bottom:
break
clk.tick(40)
display.flip()
scr.blit(bg,(0,0))
display.flip()