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
d060187c
authored
Feb 11, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
8c30006e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
my_Tetris.py
my_Tetris.py
View file @
d060187c
...
@@ -127,6 +127,22 @@ while True:
...
@@ -127,6 +127,22 @@ while True:
(
j
*
20
-
20
,
i
*
20
-
20
,
20
,
20
),
0
)
(
j
*
20
-
20
,
i
*
20
-
20
,
20
,
20
),
0
)
pygame
.
draw
.
rect
(
screen
,
(
255
,
255
,
255
),
pygame
.
draw
.
rect
(
screen
,
(
255
,
255
,
255
),
(
j
*
20
-
20
,
i
*
20
-
20
,
20
,
20
),
1
)
#在该位置画出小方块
(
j
*
20
-
20
,
i
*
20
-
20
,
20
,
20
),
1
)
#在该位置画出小方块
#创建一个新的列表new_list
new_list
=
[]
for
i
in
range
(
25
):
new_list
.
append
([
0
]
*
15
)
row_index
=
24
#定义变量row_index,表示列表的行数
for
i
in
range
(
24
,
-
1
,
-
1
):
#生成一个24→0的序列,实现从下往上对列表进行遍历
is_full
=
True
#设置is_full变量,记录满行情况
for
j
in
range
(
15
):
#对该行网格进行遍历
if
num_list
[
i
][
j
]
==
0
:
#如果该行有网格的数据为0
is_full
=
False
#is_full的值设置为false
if
is_full
==
False
:
new_list
[
row_index
]
=
num_list
[
i
]
#把该行的数据增加到新的列表中
row_index
-=
1
#列表剩余行数减一
else
:
#否则
score
+=
1
分数加
1
num_list
=
new_list
# 得分
# 得分
text_surface
=
font
.
render
(
str
(
score
),
True
,
(
0
,
0
,
0
))
text_surface
=
font
.
render
(
str
(
score
),
True
,
(
0
,
0
,
0
))
screen
.
blit
(
text_surface
,
(
350
,
70
))
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