Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson11_diy3
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
f22a8a28
authored
a year ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
9e044895
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletions
my_Tetris.py
my_Tetris.py
View file @
f22a8a28
...
@@ -7,6 +7,8 @@ grid_size = 20
...
@@ -7,6 +7,8 @@ grid_size = 20
grid_num_width
=
15
grid_num_width
=
15
grid_num_height
=
25
grid_num_height
=
25
FPS
=
30
FPS
=
30
count
=
0
states
=
False
screen
=
pygame
.
display
.
set_mode
((
460
,
500
))
screen
=
pygame
.
display
.
set_mode
((
460
,
500
))
pygame
.
display
.
set_caption
(
"俄罗斯方块"
)
pygame
.
display
.
set_caption
(
"俄罗斯方块"
)
clock
=
pygame
.
time
.
Clock
()
clock
=
pygame
.
time
.
Clock
()
...
@@ -46,7 +48,7 @@ color=random.choice(cube_colors)
...
@@ -46,7 +48,7 @@ color=random.choice(cube_colors)
def
check
(
center
):
def
check
(
center
):
for
cube
in
current_shape
:
for
cube
in
current_shape
:
cube
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
cube
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
if
cube
[
0
]
<
1
or
cube
[
1
]
<
1
or
cube
[
0
]
>
grid_num_height
_num
or
cube
[
1
]
>
grid_num_width
:
if
cube
[
0
]
<
1
or
cube
[
1
]
<
1
or
cube
[
0
]
>
grid_num_height
or
cube
[
1
]
>
grid_num_width
:
return
False
return
False
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
...
@@ -74,6 +76,11 @@ while True:
...
@@ -74,6 +76,11 @@ while True:
if
check
(
center
)
==
False
:
if
check
(
center
)
==
False
:
ID
=
old_ID
ID
=
old_ID
current_shape
=
current_x
[
ID
]
current_shape
=
current_x
[
ID
]
count
+=
1
if
count
%
FPS
==
0
:
center
[
0
]
+=
1
if
check
(
center
)
==
False
:
states
=
False
screen
.
blit
(
background
,
(
0
,
0
))
screen
.
blit
(
background
,
(
0
,
0
))
current_pos
=
[]
current_pos
=
[]
for
cube
in
current_shape
:
for
cube
in
current_shape
:
...
...
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