Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson12_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
8de9d5c4
authored
Jun 19, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
9ded14c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
my_Tetris.py
my_Tetris.py
View file @
8de9d5c4
...
@@ -56,8 +56,6 @@ num_list=[]
...
@@ -56,8 +56,6 @@ num_list=[]
for
i
in
range
(
25
):
for
i
in
range
(
25
):
num_list
.
append
([
0
]
*
15
)
num_list
.
append
([
0
]
*
15
)
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
:
if
num_list
[
cube
[
0
]
-
1
][
cube
[
1
]
-
1
]
!=
0
:
return
False
return
False
...
@@ -108,16 +106,18 @@ while True:
...
@@ -108,16 +106,18 @@ while True:
shape
=
random
.
choice
(
shape_list
)
shape
=
random
.
choice
(
shape_list
)
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
index
=
random
.
randint
(
0
,
len
(
shape
)
-
1
)
# 随机形状索引
current_shape
=
shape
[
index
]
current_shape
=
shape
[
index
]
color
=
random
.
choice
(
cube_colors
)
# 随机选取一种颜色
color
=
random
.
choice
(
cube_colors
)
# 随机选取一种颜色
count
+=
1
count
+=
1
if
count
%
FPS
==
0
:
# 降落速度的算式
if
count
%
FPS
==
0
:
# 降落速度的算式
center
[
0
]
=
center
[
0
]
+
1
center
[
0
]
=
center
[
0
]
+
1
print
(
check
(
center
))
if
check
(
center
)
==
False
:
if
check
(
center
)
==
False
:
center
[
0
]
=
center
[
0
]
-
1
center
[
0
]
=
center
[
0
]
-
1
states
=
False
states
=
False
for
cube
in
current_pos
:
for
cube
in
current_pos
:
num_list
[
cube
[
0
]
-
1
][
cube
[
1
]
-
1
]
=
color
num_list
[
cube
[
0
]
-
1
][
cube
[
1
]
-
1
]
=
color
print
(
num_list
)
# 将背景图画上去
# 将背景图画上去
screen
.
blit
(
background
,
(
0
,
0
))
screen
.
blit
(
background
,
(
0
,
0
))
...
@@ -153,8 +153,8 @@ while True:
...
@@ -153,8 +153,8 @@ while True:
if
tttt
==
False
:
if
tttt
==
False
:
new_list
[
row_index
]
=
num_list
[
i
]
new_list
[
row_index
]
=
num_list
[
i
]
row_index
-=
1
row_index
-=
1
num_list
=
new_list
else
:
score
+=
1
score
+=
1
num_list
=
new_list
num_list
=
new_list
# 得分
# 得分
text_surface
=
font
.
render
(
str
(
score
),
True
,
(
0
,
0
,
0
))
text_surface
=
font
.
render
(
str
(
score
),
True
,
(
0
,
0
,
0
))
...
...
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