-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial.py
More file actions
59 lines (55 loc) · 1.69 KB
/
tutorial.py
File metadata and controls
59 lines (55 loc) · 1.69 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'''
Tutorial.
'''
import pygame, time
import sysfiles, blocks, timing
timing.period = 1.0
fonttut = pygame.font.Font(sysfiles.hanFont(), 30)
def setDisplaySurface(disp):
global DISP
DISP = disp
def align():
timing.align()
keys = [
['W 或 ↑', '旋转方块', (600, 100)],
['S 或 ↓', '加速下降', (600, 200)],
['A 或 ←', '向左移动', (400, 200)],
['D 或 →', '向右移动', (800, 200)],
['空格', '立即降落', (600, 300)],
['Esc', '暂停游戏', (250, 100)],
['Z', '开关音乐', (420, 400)],
['X', '开关音效', (600, 400)],
['C', '调整难度', (780, 400)]
]
texts = [
'消除整行即可得分',
'方块上的汉字拼合成新的汉字也得分',
'(本游戏不对随机生成的文本内容负责)',
'方块堆到顶端即失败',
'按[空格]即可开始游戏'
]
exampleBlocks = [
blocks.Block((0, 0), '广').asPos(8, 15),
blocks.Block((0, 0), '木').asPos(9, 15),
blocks.Block((0, 0), '→').asPos(10, 15),
blocks.Block((0, 0), '床').asPos(11, 15)
]
def showKeys():
for L in keys:
fa, fb = fonttut.render(L[0], True, (255, 255, 255)), fonttut.render(L[1], True, (255, 255, 255))
fra, frb = fa.get_rect(), fb.get_rect()
fra.midbottom = L[2]
frb.midtop = L[2]
DISP.blit(fa, fra)
DISP.blit(fb, frb)
def showTexts():
midx, midy = 600, 540
for line in texts:
fl = fonttut.render(line, True, (255, 255, 255))
frl = fl.get_rect()
frl.center = (midx, midy)
DISP.blit(fl, frl)
midy += 45
def showExampleBlocks():
for bl in exampleBlocks:
bl.draw(DISP, (0, 0), (time.time() - timing.margin) % 1.0 <= 0.5)