Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson11_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
865a8fe7
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
10c738ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
my_Tetris.py
my_Tetris.py
View file @
865a8fe7
...
...
@@ -49,12 +49,14 @@ current_shape1 = random.choice(shape_list)
index
=
random
.
randint
(
0
,
len
(
current_shape1
)
-
1
)
current_shape
=
current_shape1
[
index
]
color
=
random
.
choice
(
cube_colors
)
zt1
=
0
def
cheaf
(
center
):
for
cube
in
current_shape
:
cube
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
if
cube
[
0
]
<
1
or
cube
[
1
]
<
1
or
cube
[
0
]
>
grid_num_height
or
cube
[
1
]
>
grid_num_width
:
return
False
while
True
:
old_zuobiao
=
[]
fps2
+=
1
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
...
...
@@ -91,6 +93,12 @@ while True:
zt
=
True
if
zt
:
zt
=
False
for
cube
in
current_shape
:
pos
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
current_pos
.
append
(
pos
)
for
cube
in
current_pos
:
old_zuobiao
.
append
([
cube
[
0
],
cube
[
1
],
center
,
current_shape
,
color
])
zt1
=
1
center
=
[
2
,
8
]
current_shape1
=
random
.
choice
(
shape_list
)
index
=
random
.
randint
(
0
,
len
(
current_shape1
)
-
1
)
...
...
@@ -110,6 +118,20 @@ while True:
(
cube
[
1
]
*
20
-
20
,
cube
[
0
]
*
20
-
20
,
20
,
20
),
0
)
pygame
.
draw
.
rect
(
screen
,
(
255
,
255
,
255
),
(
cube
[
1
]
*
20
-
20
,
cube
[
0
]
*
20
-
20
,
20
,
20
),
1
)
newcurrent_pos
=
[]
if
zt1
==
1
:
for
cube
in
old_zuobiao
[
3
]:
print
(
cube
)
print
(
old_zuobiao
)
pos
=
(
cube
[
0
]
+
old_zuobiao
[
2
][
0
],
cube
[
1
]
+
old_zuobiao
[
2
][
1
])
print
(
pos
)
newcurrent_pos
.
append
(
pos
)
# 取出所有小方块的行、列位置,计算坐标,绘制俄罗斯方块
for
cube
in
newcurrent_pos
:
pygame
.
draw
.
rect
(
screen
,
old_zuobiao
[
4
],
(
cube
[
1
]
*
20
-
20
,
cube
[
0
]
*
20
-
20
,
20
,
20
),
0
)
pygame
.
draw
.
rect
(
screen
,
(
255
,
255
,
255
),
(
cube
[
1
]
*
20
-
20
,
cube
[
0
]
*
20
-
20
,
20
,
20
),
1
)
# 得分
text_surface
=
font
.
render
(
str
(
score
),
True
,
(
0
,
0
,
0
))
screen
.
blit
(
text_surface
,
(
350
,
70
))
...
...
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