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
755399a4
authored
Sep 21, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
889d9ad1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
20 deletions
my_Tetris.py
my_Tetris.py
View file @
755399a4
...
@@ -16,25 +16,9 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
...
@@ -16,25 +16,9 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入素材
# 载入素材
background
=
pygame
.
image
.
load
(
'bg.png'
)
background
=
pygame
.
image
.
load
(
'bg.png'
)
font
=
pygame
.
font
.
Font
(
'STKAITI.TTF'
,
60
)
# 字体
font
=
pygame
.
font
.
Font
(
'STKAITI.TTF'
,
60
)
# 字体
def
check
():
if
event
.
key
==
locals
.
K_RIGHT
:
center
[
1
]
=
center
[
1
]
+
1
for
cube
in
fx1
:
if
cube
[
1
]
>=
15
:
center
[
1
]
-=
1
break
if
event
.
key
==
locals
.
K_LEFT
:
center
[
1
]
=
center
[
1
]
-
1
for
cube
in
fx1
:
if
cube
[
1
]
<=
1
:
center
[
1
]
+=
1
break
if
event
.
key
==
locals
.
K_DOWN
:
center
[
0
]
=
center
[
0
]
+
1
for
cube
in
fx1
:
if
cube
[
0
]
>=
25
:
center
[
0
]
-=
1
break
# 俄罗斯方块所有形状
# 俄罗斯方块所有形状
O
=
[[(
0
,
0
),
(
0
,
1
),
(
1
,
0
),
(
1
,
1
)]]
O
=
[[(
0
,
0
),
(
0
,
1
),
(
1
,
0
),
(
1
,
1
)]]
I
=
[[(
0
,
-
1
),
(
0
,
0
),
(
0
,
1
),
(
0
,
2
)],
I
=
[[(
0
,
-
1
),
(
0
,
0
),
(
0
,
1
),
(
0
,
2
)],
...
@@ -68,7 +52,30 @@ current_shape = [(0, -1), (0, 0), (0, 1), (-1, 0)]
...
@@ -68,7 +52,30 @@ current_shape = [(0, -1), (0, 0), (0, 1), (-1, 0)]
color
=
random
.
choice
(
cube_colors
)
color
=
random
.
choice
(
cube_colors
)
xg
=
random
.
choice
(
shape_list
)
xg
=
random
.
choice
(
shape_list
)
fx
=
random
.
choice
(
xg
)
fx
=
random
.
choice
(
xg
)
def
check
():
if
event
.
key
==
locals
.
K_RIGHT
:
center
[
1
]
=
center
[
1
]
+
1
for
cube
in
fx1
:
if
cube
[
1
]
>=
15
:
center
[
1
]
-=
1
break
if
event
.
key
==
locals
.
K_LEFT
:
center
[
1
]
=
center
[
1
]
-
1
for
cube
in
fx1
:
if
cube
[
1
]
<=
1
:
center
[
1
]
+=
1
break
if
event
.
key
==
locals
.
K_DOWN
:
center
[
0
]
=
center
[
0
]
+
1
for
cube
in
fx1
:
if
cube
[
0
]
>=
25
:
center
[
0
]
-=
1
break
if
event
.
key
==
locals
.
K_UP
:
fx
+=
1
if
fx
>=
len
(
xg
):
fx
=
0
current_shape
=
xg
[
fx
]
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
if
event
.
type
==
locals
.
QUIT
:
...
...
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