Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson11_diy2
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
de2c9bec
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
99520077
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
my_Tetris.py
my_Tetris.py
View file @
de2c9bec
...
...
@@ -31,9 +31,12 @@ shape_list = [I, J, L, O, S, T, Z] # 7种类型俄罗斯方块
cube_colors
=
[(
204
,
153
,
153
),
(
102
,
102
,
153
),(
153
,
0
,
102
),
(
255
,
204
,
0
),
(
204
,
0
,
51
),(
255
,
0
,
51
),
(
0
,
102
,
153
),(
153
,
0
,
51
),
(
204
,
255
,
102
),
(
255
,
153
,
0
)]
center
=
[
2
,
8
]
# 第2行第8列
a
=
random
.
choice
(
shape_list
)
k
=
random
.
randint
(
0
,
len
(
a
)
-
1
)
b
=
a
[
k
]
f
=
random
.
choice
(
cube_colors
)
k
=
True
current_pos
=
[]
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
...
...
@@ -47,25 +50,26 @@ while True:
center
[
1
]
-=
1
break
elif
event
.
key
==
locals
.
K_LEFT
:
# 向左
if
center
[
1
]
>
1
:
if
center
[
1
]
>
2
:
center
[
1
]
-=
1
for
i
in
current_pos
:
if
i
[
1
]
==-
1
:
center
[
1
]
+=
1
break
elif
event
.
key
==
locals
.
K_DOWN
:
# 向下
if
center
[
0
]
<
25
:
center
[
0
]
+=
1
elif
event
.
key
==
locals
.
K_UP
:
kxm
=
k
# 向下
k
+=
1
if
k
>=
len
(
a
):
k
=
0
for
i
in
current_pos
:
if
i
[
1
]
==
0
or
i
[
1
]
==
14
:
k
=
kxm
b
=
a
[
k
]
# 将背景图画上去
screen
.
blit
(
background
,
(
0
,
0
))
# 计算出所有小方块的行、列位置
current_pos
=
[]
if
k
==
True
:
a
=
random
.
choice
(
shape_list
)
b
=
random
.
choice
(
a
)
f
=
random
.
choice
(
cube_colors
)
k
=
False
for
cube
in
b
:
pos
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
current_pos
.
append
(
pos
)
...
...
This diff is collapsed.
Click to expand it.
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