Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson11_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
e6d3ead6
authored
Mar 24, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
47f05618
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
17 deletions
1.py
2.py
3.py
my_Tetris.py
1.py
View file @
e6d3ead6
a
=
{}
import
random
a
[
1
]
=
'abc'
i
=
0
a
[
True
]
=
234
while
True
:
a
[
False
]
=
123
a
=
input
(
"玩家:"
)
a
[
0
]
=
567
print
(
"玩家出拳:"
,
a
)
a
[
3.14
]
=
88
cq
=
[
"石头"
,
"剪刀"
,
"布"
]
a
[
"ab"
]
=
100
b
=
random
.
choice
(
cq
)
a
[(
4
,
5
)]
=
1000
print
(
"电脑出拳:"
,
b
)
for
x
in
a
.
keys
():
if
a
in
cq
:
print
(
x
)
if
a
==
b
:
for
x
in
a
.
values
():
print
(
"平局"
)
print
(
x
)
elif
a
==
"石头"
and
b
==
"剪刀"
or
a
==
"剪刀"
and
b
==
"布"
or
a
==
"布"
and
b
==
"石头"
:
for
x
,
y
in
a
.
items
():
print
(
"You Win"
)
print
(
x
,
y
)
else
:
\ No newline at end of file
print
(
"You Lose"
)
else
:
print
(
"输入错误!"
)
\ No newline at end of file
2.py
0 → 100644
View file @
e6d3ead6
import
turtle
turtle
.
speed
(
0
)
for
i
in
range
(
5
):
turtle
.
seth
(
-
15
)
turtle
.
left
(
30
*
i
)
turtle
.
circle
(
70
,
90
)
turtle
.
left
(
90
)
turtle
.
circle
(
70
,
90
)
turtle
.
hideturtle
()
turtle
.
done
()
\ No newline at end of file
3.py
0 → 100644
View file @
e6d3ead6
a
=
[
1
,
2
,
3
]
print
(
id
(
a
))
a
.
append
(
100
)
print
(
id
(
a
))
\ No newline at end of file
my_Tetris.py
View file @
e6d3ead6
...
@@ -46,16 +46,23 @@ cube_colors = [
...
@@ -46,16 +46,23 @@ cube_colors = [
(
153
,
0
,
51
),
(
204
,
255
,
102
),
(
255
,
153
,
0
)]
(
153
,
0
,
51
),
(
204
,
255
,
102
),
(
255
,
153
,
0
)]
center
=
[
2
,
8
]
# 第2行第8列
center
=
[
2
,
8
]
# 第2行第8列
current_shape
=
t
[
0
]
index
=
random
.
randint
(
0
,
len
(
t
)
-
1
)
current_shape
=
t
[
index
]
color
=
random
.
choice
(
cube_colors
)
color
=
random
.
choice
(
cube_colors
)
def
check
(
center
):
for
cube
in
current_shape
:
pos
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
if
cube
[
0
]
<
1
or
cube
[
1
]
<
1
or
cube
[
0
]
>
grid_num_width
or
cube
[
1
]
>
grid_num_height
:
return
False
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
:
exit
()
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_RIGHT
:
# 向右
if
event
.
key
==
locals
.
K_RIGHT
:
# 向右
if
center
[
1
]
<
15
:
center
[
1
]
+=
1
center
[
1
]
+=
1
if
check
(
center
)
==
False
:
center
[
1
]
-=
1
elif
event
.
key
==
locals
.
K_LEFT
:
# 向左
elif
event
.
key
==
locals
.
K_LEFT
:
# 向左
if
center
[
1
]
>
1
:
if
center
[
1
]
>
1
:
center
[
1
]
-=
1
center
[
1
]
-=
1
...
...
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