Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson3_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
c5db1035
authored
Mar 14, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
ea75c184
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
snake.py
snake.py
View file @
c5db1035
...
...
@@ -27,6 +27,7 @@ snake_head = right
apple_x
,
apple_y
=
300
,
360
score
=
0
FPSCLOCK
.
tick
(
3
)
while
True
:
for
event
in
pygame
.
event
.
get
():
...
...
@@ -48,6 +49,14 @@ while True:
snake_head
=
down
# 设置贪吃蛇的头部坐标
if
x
>
630
:
x
=
-
30
elif
x
<
0
:
x
=
660
elif
y
<
0
:
y
=
480
elif
y
>
450
:
y
=
-
30
if
setheading
==
"right"
:
x
+=
30
elif
setheading
==
"left"
:
...
...
@@ -57,14 +66,7 @@ while True:
else
:
y
+=
30
position
.
append
((
x
,
y
))
#if x > 630:
# x = -30
#if x < 0:
# x = 630
#if y < 0:
# y = 450
#if y > 450:
# y = 0
# 将背景图画上去
screen
.
blit
(
background
,
(
0
,
0
))
...
...
@@ -98,4 +100,4 @@ while True:
# 刷新画面
pygame
.
display
.
update
()
FPSCLOCK
.
tick
(
3
)
\ No newline at end of file
FPSCLOCK
.
tick
(
5
)
\ 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