Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-1-1_DIY1
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
dd1223ce
authored
May 12, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
51d712cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
29 deletions
1.py
diy1.py
1.py
View file @
dd1223ce
center
=
[
2
,
8
]
import
time
shape
=
random
.
choice
(
shape_list
)
inddex
=
random
.
rndint
(
0
,
len
(
shape
)
-
1
)
start_time
=
time
.
time
()
current_shape
=
shape
[
index
]
print
(
"开始时间为:"
,
start_time
)
color
=
rendom
.
choice
(
cube_color
)
def
check
(
center
):
list1
=
[]
for
cube
in
surrent_shape
:
for
a
in
range
(
0
,
100
):
cube
=
(
cube
[
0
]
+
center
[
0
],
cube
[
1
]
+
center
[
1
])
for
b
in
range
(
0
,
100
):
if
cube
[
0
]
<
1
or
cube
[
1
]
<
1
or
cube
[
0
]
>
grid_nu
list1
.
insert
(
0
,
0
)
or
cube
[
1
]
>
grid_nu_width
:
eend_time
=
time
.
time
()
return
False
print
(
"结束时间为:"
,
end_time
)
elif
event
.
key
==
locals
.
K_UP
:
old_index
=
Index
result
=
end_time
-
start_time
index
+=
1
print
(
"总共耗时:"
,
result
)
if
index
>=
len
(
shape
)
index
=
0
current_shape
=
shape
[
index
]
if
check
(
center
)
==
False
:
index
=
old_index
current_shape
=
shape
[
index
]
if
staes
==
False
:
states
=
True
center
=
[
2
,
8
]
shape
=
random
.
choice
(
shape_list
)
count
+=
1
states
=
False
\ No newline at end of file
diy1.py
View file @
dd1223ce
num_list
=
[]
num_list
=
[]
for
i
in
range
(
25
):
for
i
in
range
(
25
):
num_list
.
append
([
0
]
*
15
)
num_list
.
append
([
0
]
*
15
)
\ No newline at end of file
for
i
,
row
in
zip
(
range
(
1
,
26
),
num_list
):
for
j
,
colors
in
zip
(
range
(
1
,
16
),
row
)
if
colors
!=
0
:
pygame
.
draw
.
rect
(
screen
,
colors
,
(
j
*
20
-
20
,
i
*
20
-
20
,
20
,
20
))
pygame
.
draw
.
rect
(
screen
,
(
255
,
255
,
255
),
(
j
*
20
-
20
,
i
*
20
-
20
,
20
,
20
),
1
)
new_list
[]
for
i
in
range
(
25
):
new_list
.
append
([
0
]
*
15
)
row_index
=
24
for
i
in
range
(
24
,
-
1
,
-
1
):
is_full
=
True
\ No newline at end of file
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