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
4640681b
authored
May 29, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1c7e7e19
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
my_Tetris.py
my_Tetris.py
View file @
4640681b
...
@@ -40,6 +40,12 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)],
...
@@ -40,6 +40,12 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)],
[(
-
1
,
0
),
(
0
,
0
),
(
1
,
0
),
(
-
1
,
-
1
)],
[(
-
1
,
0
),
(
0
,
0
),
(
1
,
0
),
(
-
1
,
-
1
)],
[(
0
,
-
1
),
(
0
,
0
),
(
0
,
1
),
(
-
1
,
1
)]]
[(
0
,
-
1
),
(
0
,
0
),
(
0
,
1
),
(
-
1
,
1
)]]
shape_list
=
[
I
,
J
,
L
,
O
,
S
,
T
,
Z
]
# 7种类型俄罗斯方块
shape_list
=
[
I
,
J
,
L
,
O
,
S
,
T
,
Z
]
# 7种类型俄罗斯方块
num_list
=
[]
for
i
in
range
(
25
):
num_list
.
append
([
0
]
*
15
)
print
(
num_list
)
# 一些RGB颜色
# 一些RGB颜色
cube_colors
=
[
cube_colors
=
[
...
@@ -48,7 +54,10 @@ cube_colors = [
...
@@ -48,7 +54,10 @@ cube_colors = [
(
153
,
0
,
51
),
(
204
,
255
,
102
),
(
255
,
153
,
0
)]
(
153
,
0
,
51
),
(
204
,
255
,
102
),
(
255
,
153
,
0
)]
def
check
(
center
):
def
check
(
center
):
for
cube
in
current_shape
:
for
cube
in
current_shape
:
if
num_list
[
cube
[
0
]
-
1
][
cube
[
1
]
-
1
]
!=
0
:
return
False
cube
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
cube
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
# 当前的小方块超出网格的行、列,就返回False
# 当前的小方块超出网格的行、列,就返回False
if
cube
[
0
]
<
1
or
cube
[
1
]
<
1
or
cube
[
0
]
>
grid_num_height
\
if
cube
[
0
]
<
1
or
cube
[
1
]
<
1
or
cube
[
0
]
>
grid_num_height
\
...
@@ -84,6 +93,9 @@ while True:
...
@@ -84,6 +93,9 @@ while True:
if
check
(
center
)
==
False
:
if
check
(
center
)
==
False
:
index
=
old_index
index
=
old_index
current_shape
=
shape
[
index
]
current_shape
=
shape
[
index
]
current_pos
=
[]
for
cube
in
current_pos
:
num_list
[
cube
[
0
]
-
1
][
cube
[
1
]
-
1
]
=
color
if
states
==
False
:
if
states
==
False
:
states
=
True
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