Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson12_diy01
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0c4c8d88
authored
Sep 24, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
0687e059
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
my_Tetris.py
my_Tetris.py
View file @
0c4c8d88
...
...
@@ -133,6 +133,25 @@ while True:
(
j
*
20
-
20
,
i
*
20
-
20
,
20
,
20
))
pygame
.
draw
.
rect
(
screen
,
(
255
,
255
,
255
),
(
j
*
20
-
20
,
i
*
20
-
20
,
20
,
20
),
1
)
# 新的地图列表
new_list
=
[]
# 给新的空白列表命名为new_list
for
i
in
range
(
25
):
# 使用for循环让程序重复执行25次
new_list
.
append
([
0
]
*
15
)
# 用num_list.append()方法将小列表添加到大列表里
# 新建变量row_index用于记录新网格列表改变的行数序号,并设为24,表示最后一行
row_index
=
24
for
i
in
range
(
24
,
-
1
,
-
1
):
# 结合for循环生成一个倒着排序的列表索引
# (确认每一行网格有没有被小方块填满)
is_full
=
True
# 建立变量is_full并设为True默认网格状态被小方块填满
for
j
in
range
(
grid_num_width
):
# for循环取出这一行网格的每一小格检查
if
num_list
[
i
][
j
]
==
0
:
# if判断这一行网格的每一小格的值是否等于0
is_full
=
False
# 如果等于0,说明还有格子没有填满,就将值设为False
if
is_full
==
False
:
# if判断这一行有没有被填满
new_list
[
row_index
]
=
num_list
[
i
]
# 通过下标将这一行数值赋值到新列表里
row_index
-=
1
# 将序列号减少1
else
:
# 否则(这一行填满)
score
+=
1
# 分数变量score增加1
num_list
=
new_list
# 网格列表的值new_list赋值给变量num_list,替换原来的数值
# 得分
text_surface
=
font
.
render
(
str
(
score
),
True
,
(
0
,
0
,
0
))
screen
.
blit
(
text_surface
,
(
350
,
70
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment