Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson12_diy4
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
eae7149a
authored
Aug 19, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
35d87765
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
5 deletions
my_Tetris.py
my_Tetris.py
View file @
eae7149a
...
...
@@ -39,7 +39,7 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)],
[(
0
,
-
1
),
(
0
,
0
),
(
0
,
1
),
(
1
,
-
1
)],
[(
-
1
,
0
),
(
0
,
0
),
(
1
,
0
),
(
-
1
,
-
1
)],
[(
0
,
-
1
),
(
0
,
0
),
(
0
,
1
),
(
-
1
,
1
)]]
shape_list
=
[
I
,
J
,
L
,
O
,
S
,
T
,
Z
]
# 7种类型俄罗斯方块
shape_list
=
[
O
,
I
,
L
,
S
,
Z
,
T
,
J
]
# 7种类型俄罗斯方块
# 一些RGB颜色
cube_colors
=
[
...
...
@@ -77,10 +77,10 @@ while True:
if
check
(
center
)
==
False
:
center
[
1
]
=
center
[
1
]
-
1
elif
event
.
key
==
locals
.
K_DOWN
:
# 向下
center
[
0
]
=
center
[
0
]
+
1
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
-
1
elif
event
.
key
==
locals
.
K_DOWN
:
while
(
check
(
center
)
!=
False
):
# 向下
center
[
0
]
=
center
[
0
]
+
1
center
[
0
]
=
center
[
0
]
-
1
elif
event
.
key
==
locals
.
K_UP
:
# 向上键
old_index
=
index
...
...
@@ -91,6 +91,62 @@ while True:
if
check
(
center
)
==
False
:
index
=
old_index
current_shape
=
shape
[
index
]
elif
event
.
key
==
locals
.
K_i
:
# 向下
center
[
0
]
=
center
[
0
]
-
1
shape
=
shape_list
[
1
]
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
current_shape
=
shape
[
index
]
color
=
random
.
choice
(
cube_colors
)
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
+
1
elif
event
.
key
==
locals
.
K_o
:
# 向下
center
[
0
]
=
center
[
0
]
-
1
shape
=
shape_list
[
0
]
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
current_shape
=
shape
[
index
]
color
=
random
.
choice
(
cube_colors
)
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
+
1
elif
event
.
key
==
locals
.
K_l
:
# 向下
center
[
0
]
=
center
[
0
]
-
1
shape
=
shape_list
[
2
]
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
current_shape
=
shape
[
index
]
color
=
random
.
choice
(
cube_colors
)
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
+
1
elif
event
.
key
==
locals
.
K_s
:
# 向下
center
[
0
]
=
center
[
0
]
-
1
shape
=
shape_list
[
3
]
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
current_shape
=
shape
[
index
]
color
=
random
.
choice
(
cube_colors
)
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
+
1
elif
event
.
key
==
locals
.
K_z
:
# 向下
center
[
0
]
=
center
[
0
]
-
1
shape
=
shape_list
[
4
]
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
current_shape
=
shape
[
index
]
color
=
random
.
choice
(
cube_colors
)
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
+
1
elif
event
.
key
==
locals
.
K_t
:
# 向下
center
[
0
]
=
center
[
0
]
-
1
shape
=
shape_list
[
5
]
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
current_shape
=
shape
[
index
]
color
=
random
.
choice
(
cube_colors
)
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
+
1
elif
event
.
key
==
locals
.
K_j
:
# 向下
center
[
0
]
=
center
[
0
]
-
1
shape
=
shape_list
[
6
]
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
current_shape
=
shape
[
index
]
color
=
random
.
choice
(
cube_colors
)
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
+
1
if
gameover
==
False
:
if
states
==
False
:
states
=
True
...
...
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