Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson12_diy3
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
d3415bce
authored
Aug 15, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
bc1e7e19
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
my_Tetris.py
my_Tetris.py
View file @
d3415bce
...
...
@@ -58,16 +58,25 @@ def check(center):
return
False
if
num_list
[
cube
[
0
]
-
1
][
cube
[
1
]
-
1
]
!=
0
:
return
False
gameover
=
False
font2
=
pygame
.
font
.
Font
(
'STKAITI.TTF'
,
15
)
while
True
:
if
num_list
[
1
][
7
]
!=
0
:
gameover
=
True
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
gameover
==
True
:
num_list
=
[]
for
i
in
range
(
25
):
num_list
.
append
([
0
]
*
15
)
if
event
.
key
==
locals
.
K_LEFT
:
# 向左
center
[
1
]
=
center
[
1
]
-
1
# 左移1列
if
check
(
center
)
==
False
:
center
[
1
]
=
center
[
1
]
+
1
# 右移1列
center
[
1
]
=
center
[
1
]
+
1
# 右移1列
elif
event
.
key
==
locals
.
K_RIGHT
:
# 向右
center
[
1
]
=
center
[
1
]
+
1
...
...
@@ -89,6 +98,7 @@ while True:
index
=
old_index
current_shape
=
shape
[
index
]
if
gameover
==
False
:
if
states
==
False
:
states
=
True
center
=
[
2
,
8
]
# 第2行第8列
...
...
@@ -142,6 +152,10 @@ while True:
# 得分
text_surface
=
font
.
render
(
str
(
score
),
True
,
(
0
,
0
,
0
))
screen
.
blit
(
text_surface
,
(
350
,
70
))
else
:
text
=
font2
.
render
(
"游戏结束,请按任意键开始游戏"
,
True
,(
0
,
0
,
0
))
screen
.
blit
(
text
,(
50
,
300
))
# 刷新画面
pygame
.
display
.
update
()
clock
.
tick
(
FPS
)
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