Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson2_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
12762a65
authored
Nov 20, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
f7977280
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
6 deletions
1.py
2.py
3.py
snake.py
1.py
0 → 100644
View file @
12762a65
import
turtle
turtle
.
speed
(
1
)
turtle
.
penup
()
turtle
.
goto
(
-
100
,
100
)
turtle
.
pendown
()
for
i
in
range
(
4
):
turtle
.
forward
(
200
)
turtle
.
right
(
90
)
turtle
.
goto
(
0
,
100
)
turtle
.
color
(
"black"
,
"red"
)
turtle
.
begin_fill
()
turtle
.
goto
(
100
,
0
)
turtle
.
goto
(
0
,
-
100
)
turtle
.
goto
(
-
100
,
0
)
turtle
.
goto
(
0
,
100
)
turtle
.
end_fill
()
turtle
.
hideturtle
()
turtle
.
done
()
\ No newline at end of file
2.py
0 → 100644
View file @
12762a65
a
=
int
(
input
(
"乌龟爬行的速度:"
))
b
=
100
/
a
print
(
"乌龟能够追上兔子的时间为:"
,
b
,
"秒"
,
sep
=
""
)
3.py
0 → 100644
View file @
12762a65
# a=float(input("输入半径:"))
# pi=3.14
# print("圆的周长是%.2f,面积是%.2f"%(2*pi*a,pi*a**2))
# print("圆的周长是{:.2f},面积是{:.2f}".format(2*pi*a,pi*a**2))
a
=
10
print
(
eval
(
'a+10'
))
\ No newline at end of file
snake.py
View file @
12762a65
...
...
@@ -13,6 +13,7 @@ right = pygame.image.load('right.png')
food
=
pygame
.
image
.
load
(
'apple.png'
)
body
=
pygame
.
image
.
load
(
'body.png'
)
x
,
y
=
240
,
120
pos
=
[(
180
,
90
),(
180
,
120
),(
210
,
120
),(
x
,
y
)]
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
...
...
@@ -20,15 +21,18 @@ while True:
exit
()
# 将背景图画上去
x
+=
30
pos
.
append
((
x
,
y
))
pos
.
pop
(
0
)
screen
.
blit
(
background
,
(
0
,
0
))
# 将贪吃蛇画上去
screen
.
blit
(
right
,
(
x
,
y
)
)
screen
.
blit
(
right
,
pos
[
-
1
]
)
# 将贪吃蛇的身体画上去
screen
.
blit
(
body
,
(
210
,
120
))
screen
.
blit
(
body
,
(
180
,
120
))
screen
.
blit
(
body
,
(
180
,
90
))
for
i
in
range
(
len
(
pos
)
-
1
):
screen
.
blit
(
body
,
pos
[
i
])
# screen.blit(body, (180, 120))
# screen.blit(body, (180, 90))
# 将果实画上去
screen
.
blit
(
food
,
(
360
,
300
))
# 刷新画面
pygame
.
display
.
update
()
a
.
tick
(
100
)
\ No newline at end of file
a
.
tick
(
3
)
\ 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