Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson10_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
5732b4b7
authored
Sep 08, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
967100e5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
my_Tetris.py
my_Tetris.py
View file @
5732b4b7
...
@@ -52,11 +52,11 @@ cube_colors = [
...
@@ -52,11 +52,11 @@ cube_colors = [
(
153
,
0
,
51
),
(
204
,
255
,
102
),
(
255
,
153
,
0
)]
(
153
,
0
,
51
),
(
204
,
255
,
102
),
(
255
,
153
,
0
)]
color
=
random
.
choice
(
cube_colors
)
color
=
random
.
choice
(
cube_colors
)
center
=
[
2
,
8
]
# 第2行第8列
center
=
[
2
,
8
]
# 第2行第8列
# def chea
k(center):
def
chec
k
(
center
):
#
for cube in current_shape:
for
cube
in
current_shape
:
# pos
= (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 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
:
...
@@ -66,16 +66,16 @@ while True:
...
@@ -66,16 +66,16 @@ while True:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_RIGHT
:
# 向右
if
event
.
key
==
locals
.
K_RIGHT
:
# 向右
center
[
1
]
+=
1
center
[
1
]
+=
1
# if chea
k(center)==False:
if
chec
k
(
center
)
==
False
:
#
center[1] -= 1
center
[
1
]
-=
1
elif
event
.
key
==
locals
.
K_LEFT
:
elif
event
.
key
==
locals
.
K_LEFT
:
center
[
1
]
-=
1
# 向左
center
[
1
]
-=
1
# 向左
# if chea
k(center)==False:
if
chec
k
(
center
)
==
False
:
#
center[1] += 1
center
[
1
]
+=
1
elif
event
.
key
==
locals
.
K_DOWN
:
elif
event
.
key
==
locals
.
K_DOWN
:
center
[
0
]
+=
1
# 向下
center
[
0
]
+=
1
# 向下
# if chea
k(center)==False:
if
chec
k
(
center
)
==
False
:
#
center[0] -= 1
center
[
0
]
-=
1
# 将背景图画上去
# 将背景图画上去
screen
.
blit
(
background
,
(
0
,
0
))
screen
.
blit
(
background
,
(
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